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.ListReleasesResponseOrBuilder; 023 024import org.apache.maven.plugin.logging.Log; 025 026/** 027 * A {@link ReleaseDiscoveryListener} that {@linkplain 028 * Log#info(CharSequence) logs} the {@link 029 * hapi.services.tiller.Tiller.ListReleasesResponseOrBuilder} 030 * {@linkplain 031 * ReleaseDiscoveryEvent#getListReleasesResponseOrBuilder() associated 032 * with a <code>ReleaseDiscoveryEvent</code>}. 033 * 034 * @author <a href="https://about.me/lairdnelson" 035 * target="_parent">Laird Nelson</a> 036 * 037 * @see ReleaseDiscoveryEvent 038 * 039 * @see ReleaseDiscoveryListener 040 */ 041public class AbstractReleaseDiscoveryListener implements ReleaseDiscoveryListener { 042 043 044 /* 045 * Constructors. 046 */ 047 048 049 /** 050 * Creates a new {@link AbstractReleaseDiscoveryListener}. 051 */ 052 public AbstractReleaseDiscoveryListener() { 053 super(); 054 } 055 056 057 058 /* 059 * Instance methods. 060 */ 061 062 063 /** 064 * {@linkplain Log#info(CharSequence) Logs} the {@link 065 * hapi.services.tiller.Tiller.ListReleasesResponseOrBuilder} 066 * {@linkplain 067 * ReleaseDiscoveryEvent#getListReleasesResponseOrBuilder() 068 * associated with a <code>ReleaseDiscoveryEvent</code>}. 069 * 070 * @param event the {@link ReleaseDiscoveryEvent} describing the 071 * release; may be {@code null} in which case no action will be 072 * taken 073 * 074 * @see ReleaseDiscoveryEvent 075 * 076 * @see 077 * hapi.services.tiller.Tiller.ListReleasesResponse#toString() 078 */ 079 @Override 080 public void releaseDiscovered(final ReleaseDiscoveryEvent event) { 081 if (event != null) { 082 final Log log = event.getLog(); 083 if (log != null && log.isInfoEnabled()) { 084 log.info(String.valueOf(event.getListReleasesResponseOrBuilder())); 085 } 086 } 087 } 088 089}