- Type Parameters:
T- the type of data propagated to listeners.
- All Known Subinterfaces:
CalendarPanel.CalendarDate,CalendarPanel.CalendarDateTime,ComponentValue<C,,T> EntityEditModel.EditorValue<T>,EntityEditModel.EntityEditor,EntityEditModel.EntityEditor.Exists,EntityEditModel.EntityEditor.Modified,EntityQueryModel.AdditionalCondition,Event<T>,FilterModel.IncludedItems<T>,FilterModel.IncludedPredicate<T>,FilterTableColumnModel.ColumnSelection.ColumnIndex,FilterTableColumnModel.HiddenColumns<C>,FilterTableColumnModel.VisibleColumns<C>,FilterTableSearchModel.Results,MultiSelection.Indexes,MultiSelection.Items<R>,Observable<T>,ObservableState,ObservableValueCollection<T,,C> ObservableValueList<T>,ObservableValueSet<T>,State,State.Combination,Value<T>,ValueCollection<T,,C> ValueList<T>,ValueSet<T>
- All Known Implementing Classes:
AbstractComponentValue,AbstractTextComponentValue,AbstractValue,PropertyValue
public interface Observer<T>
Manages event listeners. Implemented by
Event.
All implementations are thread-safe and support concurrent access.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanaddConsumer(Consumer<? super T> consumer) Addsconsumerto thisObserver.booleanaddListener(Runnable listener) Addslistenerto thisObserver.booleanaddWeakConsumer(Consumer<? super T> consumer) Uses aWeakReference, addingconsumerdoes not prevent it from being garbage collected.booleanaddWeakListener(Runnable listener) Uses aWeakReference, addinglistenerdoes not prevent it from being garbage collected.booleanremoveConsumer(Consumer<? super T> consumer) Removesconsumerfrom thisObserverbooleanremoveListener(Runnable listener) Removeslistenerfrom thisObserverbooleanremoveWeakConsumer(Consumer<? super T> consumer) Removesconsumerfrom thisObserver.booleanremoveWeakListener(Runnable listener) Removeslistenerfrom thisObserver
-
Method Details
-
addListener
Addslistenerto thisObserver. 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
Removeslistenerfrom thisObserver- Parameters:
listener- the listener to remove- Returns:
- true if this observer contained the specified listener
-
addConsumer
Addsconsumerto thisObserver. Adding the same consumer a second time has no effect.- Parameters:
consumer- the consumer to add- Returns:
- true if this observer did not already contain the specified consumer
- Throws:
NullPointerException- in case consumer is null
-
removeConsumer
Removesconsumerfrom thisObserver- Parameters:
consumer- the consumer to remove- Returns:
- true if this observer contained the specified consumer
-
addWeakListener
Uses aWeakReference, addinglistenerdoes not prevent it from being garbage collected. Adding the same listener a second time has no effect.Note: Dead weak references accumulate until cleaned up, which happens automatically when listeners are added or removed. To trigger cleanup manually without modifying the listener set, call
removeWeakListener(Runnable)with any non-existing listener:// Clean up dead weak references observer.removeWeakListener(() -> {});- Parameters:
listener- the listener- Returns:
- true if this observer did not already contain the specified listener
-
removeWeakListener
Removeslistenerfrom thisObserver- Parameters:
listener- the listener to remove- Returns:
- true if this observer contained the specified listener
-
addWeakConsumer
Uses aWeakReference, addingconsumerdoes not prevent it from being garbage collected. Adding the same consumer a second time has no effect.Note: Dead weak references accumulate until cleaned up, which happens automatically when listeners are added or removed. To trigger cleanup manually without modifying the listener set, call
removeWeakConsumer(Consumer)with any non-existing consumer:// Clean up dead weak references observer.removeWeakConsumer(data -> {});- Parameters:
consumer- the consumer- Returns:
- true if this observer did not already contain the specified consumer
-
removeWeakConsumer
Removesconsumerfrom thisObserver.- Parameters:
consumer- the consumer to remove- Returns:
- true if this observer contained the specified consumer
-