- All Known Subinterfaces:
EntityEditModel.EntityEditor.Exists,EntityEditModel.EntityEditor.Modified,State,State.Combination
Specifies an observable for a
State instance.-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanaddConsumer(Consumer<? super Boolean> consumer) Addsconsumerto thisObserver.default booleanaddListener(Runnable listener) Addslistenerto thisObserver.default booleanaddWeakConsumer(Consumer<? super Boolean> consumer) Uses aWeakReference, addingconsumerdoes not prevent it from being garbage collected.default booleanaddWeakListener(Runnable listener) Uses aWeakReference, addinglistenerdoes not prevent it from being garbage collected.booleanis()not()observer()default booleanremoveConsumer(Consumer<? super Boolean> consumer) Removesconsumerfrom thisObserverdefault booleanremoveListener(Runnable listener) Removeslistenerfrom thisObserverdefault booleanremoveWeakConsumer(Consumer<? super Boolean> consumer) Removesconsumerfrom thisObserver.default booleanremoveWeakListener(Runnable listener) Removeslistenerfrom thisObserver
-
Method Details
-
is
boolean is()- Returns:
- the value of this state
-
not
ObservableState not()- Returns:
- A
ObservableStateinstance that is always the reverse of thisObservableStateinstance
-
observer
- Returns:
- an
Observernotified each time the observed value may have changed
-
addListener
Description copied from interface:ObserverAddslistenerto thisObserver. Adding the same listener a second time has no effect.- Specified by:
addListenerin interfaceObserver<Boolean>- Parameters:
listener- the listener to add- Returns:
- true if this observer did not already contain the specified listener
-
removeListener
Description copied from interface:ObserverRemoveslistenerfrom thisObserver- Specified by:
removeListenerin interfaceObserver<Boolean>- Parameters:
listener- the listener to remove- Returns:
- true if this observer contained the specified listener
-
addConsumer
Description copied from interface:ObserverAddsconsumerto thisObserver. Adding the same consumer a second time has no effect.- Specified by:
addConsumerin interfaceObserver<Boolean>- Parameters:
consumer- the consumer to add- Returns:
- true if this observer did not already contain the specified consumer
-
removeConsumer
Description copied from interface:ObserverRemovesconsumerfrom thisObserver- Specified by:
removeConsumerin interfaceObserver<Boolean>- Parameters:
consumer- the consumer to remove- Returns:
- true if this observer contained the specified consumer
-
addWeakListener
Description copied from interface:ObserverUses 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
Observer.removeWeakListener(Runnable)with any non-existing listener:// Clean up dead weak references observer.removeWeakListener(() -> {});- Specified by:
addWeakListenerin interfaceObserver<Boolean>- Parameters:
listener- the listener- Returns:
- true if this observer did not already contain the specified listener
-
removeWeakListener
Description copied from interface:ObserverRemoveslistenerfrom thisObserver- Specified by:
removeWeakListenerin interfaceObserver<Boolean>- Parameters:
listener- the listener to remove- Returns:
- true if this observer contained the specified listener
-
addWeakConsumer
Description copied from interface:ObserverUses 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
Observer.removeWeakConsumer(Consumer)with any non-existing consumer:// Clean up dead weak references observer.removeWeakConsumer(data -> {});- Specified by:
addWeakConsumerin interfaceObserver<Boolean>- Parameters:
consumer- the consumer- Returns:
- true if this observer did not already contain the specified consumer
-
removeWeakConsumer
Description copied from interface:ObserverRemovesconsumerfrom thisObserver.- Specified by:
removeWeakConsumerin interfaceObserver<Boolean>- Parameters:
consumer- the consumer to remove- Returns:
- true if this observer contained the specified consumer
-