| 
01 /*02  * Copyright 2008-2015 the original author or authors.
 03  *
 04  * Licensed under the Apache License, Version 2.0 (the "License");
 05  * you may not use this file except in compliance with the License.
 06  * You may obtain a copy of the License at
 07  *
 08  *     http://www.apache.org/licenses/LICENSE-2.0
 09  *
 10  * Unless required by applicable law or agreed to in writing, software
 11  * distributed under the License is distributed on an "AS IS" BASIS,
 12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  * See the License for the specific language governing permissions and
 14  * limitations under the License.
 15  */
 16 package griffon.core;
 17
 18 import javax.annotation.Nonnull;
 19 import javax.annotation.Nullable;
 20 import java.beans.PropertyChangeListener;
 21
 22 /**
 23  * Describes objects that provide bound properties as specified in the
 24  * <a href="http://docs.oracle.com/javase/tutorial/javabeans/TOC.html">Java
 25  * Bean Specification</a>.
 26  *
 27  * @author Andres Almiray
 28  * @since 2.0.0
 29  */
 30 public interface Observable {
 31     /**
 32      * Adds the given PropertyChangeListener to the listener list.<p>
 33      * The listener is registered for all bound properties of this class.
 34      *
 35      * @param listener the PropertyChangeListener to be added
 36      * @see #removePropertyChangeListener(PropertyChangeListener)
 37      */
 38     void addPropertyChangeListener(@Nullable PropertyChangeListener listener);
 39
 40     /**
 41      * Removes the given PropertyChangeListener from the listener list.<p>
 42      * The listener is registered an specific property of this class.
 43      *
 44      * @param propertyName The name of the property to listen on.
 45      * @param listener     the PropertyChangeListener to be added
 46      * @see #removePropertyChangeListener(String, PropertyChangeListener)
 47      */
 48     void addPropertyChangeListener(@Nullable String propertyName, @Nullable PropertyChangeListener listener);
 49
 50     /**
 51      * Removes the given PropertyChangeListener from the listener list.<p>
 52      * This method should be used to remove PropertyChangeListeners that were
 53      * registered for all bound properties of this class.
 54      *
 55      * @param listener the PropertyChangeListener to be removed
 56      * @see #addPropertyChangeListener(PropertyChangeListener)
 57      */
 58     void removePropertyChangeListener(@Nullable PropertyChangeListener listener);
 59
 60     /**
 61      * Removes the given PropertyChangeListener from the listener list.<p>
 62      * This method should be used to remove PropertyChangeListeners that were
 63      * registered for an specific property of this class.
 64      *
 65      * @param propertyName The name of the property that was listened on.
 66      * @param listener     the PropertyChangeListener to be removed
 67      * @see #addPropertyChangeListener(String, PropertyChangeListener)
 68      */
 69     void removePropertyChangeListener(@Nullable String propertyName, @Nullable PropertyChangeListener listener);
 70
 71     /**
 72      * Returns an array of all the listeners that were added with addPropertyChangeListener().<p>
 73      *
 74      * @return all of the {@code PropertyChangeListeners} added or an empty array if no
 75      *         listeners have been added.
 76      */
 77     @Nonnull
 78     PropertyChangeListener[] getPropertyChangeListeners();
 79
 80     /**
 81      * Returns an array of all the listeners which have been associated
 82      * with the named property.
 83      *
 84      * @param propertyName The name of the property being listened to
 85      * @return all of the <code>PropertyChangeListeners</code> associated with
 86      *         the named property.  If no such listeners have been added,
 87      *         or if <code>propertyName</code> is null, an empty array is
 88      *         returned.
 89      */
 90     @Nonnull
 91     PropertyChangeListener[] getPropertyChangeListeners(@Nullable String propertyName);
 92 }
 |