Interface EventObserver<T>

Type Parameters:
T - the type of data propagated with the event.
All Known Subinterfaces:
ComponentValue<T,C>, Event<T>, PropertyValue<T>, State, State.Combination, StateObserver, Value<T>, ValueObserver<T>, ValueSet<T>, ValueSetObserver<T>
All Known Implementing Classes:
AbstractComponentValue, AbstractTextComponentValue, AbstractValue

public interface EventObserver<T>
Manages listeners for an Event.
  • Method Details

    • addListener

      boolean addListener(Runnable listener)
      Adds listener to this EventObserver. Adding the same listener a second time has no effect.
      Parameters:
      listener - the listener to add
      Returns:
      true if this observer did not already contain the specified listener
      Throws:
      NullPointerException - in case listener is null
    • removeListener

      boolean removeListener(Runnable listener)
      Removes listener from this EventObserver
      Parameters:
      listener - the listener to remove
      Returns:
      true if this observer contained the specified listener
    • addDataListener

      boolean addDataListener(Consumer<? super T> listener)
      Adds listener to this EventObserver. Adding the same listener a second time has no effect.
      Parameters:
      listener - the listener to add
      Returns:
      true if this observer did not already contain the specified listener
      Throws:
      NullPointerException - in case listener is null
    • removeDataListener

      boolean removeDataListener(Consumer<? super T> listener)
      Removes listener from this EventObserver
      Parameters:
      listener - the listener to remove
      Returns:
      true if this observer contained the specified listener
    • addWeakListener

      boolean addWeakListener(Runnable listener)
      Uses a WeakReference, adding listener does not prevent it from being garbage collected. Adding the same listener a second time has no effect.
      Parameters:
      listener - the listener
      Returns:
      true if this observer did not already contain the specified listener
    • removeWeakListener

      boolean removeWeakListener(Runnable listener)
      Removes listener from this EventObserver
      Parameters:
      listener - the listener to remove
      Returns:
      true if this observer contained the specified listener
    • addWeakDataListener

      boolean addWeakDataListener(Consumer<? super T> listener)
      Uses a WeakReference, adding listener does not prevent it from being garbage collected. Adding the same listener a second time has no effect.
      Parameters:
      listener - the listener
      Returns:
      true if this observer did not already contain the specified listener
    • removeWeakDataListener

      boolean removeWeakDataListener(Consumer<? super T> listener)
      Removes listener from this EventObserver.
      Parameters:
      listener - the listener to remove
      Returns:
      true if this observer contained the specified listener