/******************************************************************************* * Copyright 2012 Geoscience Australia * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package au.gov.ga.earthsci.common.util; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; /** * Represents a bean that supports listening to with * {@link PropertyChangeListener}s. * * @author Michael de Hoog (michael.dehoog@ga.gov.au) */ public interface IPropertyChangeBean { /** * Fire an existing PropertyChangeEvent to any registered listeners. No * event is fired if the given event's old and new values are equal and * non-null. * * @param evt * The PropertyChangeEvent object. */ void firePropertyChange(PropertyChangeEvent propertyChangeEvent); /** * Report a bound property update to any registered listeners. No event is * fired if old and new are equal and non-null. * * <p> * This is merely a convenience wrapper around the more general * firePropertyChange method that takes {@code PropertyChangeEvent} value. * * @param propertyName * The programmatic name of the property that was changed. * @param oldValue * The old value of the property. * @param newValue * The new value of the property. */ void firePropertyChange(String propertyName, Object oldValue, Object newValue); /** * Add a PropertyChangeListener to the listener list. The listener is * registered for all properties. The same listener object may be added more * than once, and will be called as many times as it is added. If * <code>listener</code> is null, no exception is thrown and no action is * taken. * * @param listener * The PropertyChangeListener to be added */ void addPropertyChangeListener(PropertyChangeListener listener); /** * Remove a PropertyChangeListener from the listener list. This removes a * PropertyChangeListener that was registered for all properties. If * <code>listener</code> was added more than once to the same event source, * it will be notified one less time after being removed. If * <code>listener</code> is null, or was never added, no exception is thrown * and no action is taken. * * @param listener * The PropertyChangeListener to be removed */ void removePropertyChangeListener(PropertyChangeListener listener); /** * Add a PropertyChangeListener for a specific property. The listener will * be invoked only when a call on firePropertyChange names that specific * property. The same listener object may be added more than once. For each * property, the listener will be invoked the number of times it was added * for that property. If <code>propertyName</code> or <code>listener</code> * is null, no exception is thrown and no action is taken. * * @param propertyName * The name of the property to listen on. * @param listener * The PropertyChangeListener to be added */ void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); /** * Remove a PropertyChangeListener for a specific property. If * <code>listener</code> was added more than once to the same event source * for the specified property, it will be notified one less time after being * removed. If <code>propertyName</code> is null, no exception is thrown and * no action is taken. If <code>listener</code> is null, or was never added * for the specified property, no exception is thrown and no action is * taken. * * @param propertyName * The name of the property that was listened on. * @param listener * The PropertyChangeListener to be removed */ void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); }