001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
002 *
003 * Copyright © 2017 MicroBean.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
014 * implied.  See the License for the specific language governing
015 * permissions and limitations under the License.
016 */
017package org.microbean.helm.maven;
018
019import java.util.EventListener;
020import java.util.Objects;
021
022import hapi.services.tiller.Tiller.GetHistoryResponseOrBuilder;
023
024import org.apache.maven.plugin.logging.Log;
025
026/**
027 * A {@link ReleaseHistoryListener} that {@linkplain
028 * Log#info(CharSequence) logs} the {@link
029 * hapi.services.tiller.Tiller.GetHistoryResponseOrBuilder}
030 * {@linkplain
031 * ReleaseHistoryEvent#getHistoryResponseOrBuilder() associated
032 * with a <code>ReleaseHistoryEvent</code>}.
033 *
034 * @author <a href="https://about.me/lairdnelson"
035 * target="_parent">Laird Nelson</a>
036 *
037 * @see ReleaseHistoryEvent
038 *
039 * @see ReleaseHistoryListener
040 */
041public class AbstractReleaseHistoryListener implements ReleaseHistoryListener {
042
043
044  /*
045   * Constructors.
046   */
047
048
049  /**
050   * Creates a new {@link AbstractReleaseHistoryListener}.
051   */
052  public AbstractReleaseHistoryListener() {
053    super();
054  }
055
056
057  /*
058   * Instance methods.
059   */
060  
061
062  /**
063   * {@linkplain Log#info(CharSequence) Logs} the {@link
064   * hapi.services.tiller.Tiller.GetHistoryResponseOrBuilder}
065   * {@linkplain ReleaseHistoryEvent#getHistoryResponseOrBuilder()
066   * associated with a <code>ReleaseHistoryEvent</code>}.
067   *
068   * @param event the {@link ReleaseHistoryEvent} describing the
069   * release; may be {@code null} in which case no action will be
070   * taken
071   *
072   * @see ReleaseHistoryEvent
073   *
074   * @see
075   * hapi.services.tiller.Tiller.GetHistoryResponse#toString()
076   */
077  @Override
078  public void releaseHistoryRetrieved(final ReleaseHistoryEvent event) {
079    if (event != null) {
080      final GetHistoryResponseOrBuilder getHistoryResponseOrBuilder = event.getHistoryResponseOrBuilder();
081      final Log log = event.getLog();
082      if (log != null && log.isInfoEnabled()) {
083        log.info(String.valueOf(getHistoryResponseOrBuilder));
084      }
085    }
086  }
087  
088}