Package io.github.mmm.value.observable
Class AbstractObservableValue<V>
java.lang.Object
io.github.mmm.event.AbstractEventSource<ObservableEvent<V>,ObservableEventListener<? super V>>
io.github.mmm.event.AbstractEventSender<ObservableEvent<V>,ObservableEventListener<? super V>>
io.github.mmm.value.observable.AbstractObservableValue<V>
- Type Parameters:
V- type of the observablevalue.
- All Implemented Interfaces:
EventSource<ObservableEvent<V>,,ObservableEventListener<? super V>> ObservableValue<V>,ReadableValue<V>,Supplier<V>
- Direct Known Subclasses:
AbstractWritableObservableValue,Binding
public abstract class AbstractObservableValue<V>
extends AbstractEventSender<ObservableEvent<V>,ObservableEventListener<? super V>>
implements ObservableValue<V>
Abstract base implementation of
ObservableValue that handles ObservableEventListeners.- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoAddListener(EventListener<ObservableEvent<V>> listener) protected voidfireChange(Object change) Fires a defaultvalue changeevent.protected voidFires a default value change event.protected booleanfireEvent(ObservableEvent<V> event) protected voidfireEventFor(AbstractObservableValue<?> observable) protected <T> voidfireEventFor(AbstractObservableValue<T> observable, ObservableEvent<T> event) protected voidfireEventWithOldValue(V oldValue) Fires a default value change event if theold valueis known (currently available anyhow).protected booleanprotected voidInvalidates this observable in case it's value is computed.booleanremoveListener(ObservableEventListener<? super V> listener) final StringtoString()voidMethods inherited from class io.github.mmm.event.AbstractEventSender
getEventAdapter, hasListeners, makeReadOnlyMethods inherited from class io.github.mmm.event.AbstractEventSource
addListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.mmm.event.EventSource
addListener, addListener, addWeakListenerMethods inherited from interface io.github.mmm.value.ReadableValue
get, getFallbackSafeValue, getSafe, getValueClass
-
Constructor Details
-
AbstractObservableValue
public AbstractObservableValue()The constructor.
-
-
Method Details
-
doAddListener
- Overrides:
doAddListenerin classAbstractEventSender<ObservableEvent<V>,ObservableEventListener<? super V>>
-
removeListener
- Specified by:
removeListenerin interfaceEventSource<ObservableEvent<V>,ObservableEventListener<? super V>> - Overrides:
removeListenerin classAbstractEventSender<ObservableEvent<V>,ObservableEventListener<? super V>>
-
hasChangeAwareListeners
protected boolean hasChangeAwareListeners()- Returns:
trueif at least oneChangeAwareObservableEventListenerisregistered,falseotherwise (to avoid building andsendingchanges for better performance).
-
fireEvent
protected void fireEvent()Fires a default value change event.- See Also:
-
fireEventWithOldValue
Fires a default value change event if theold valueis known (currently available anyhow).- Parameters:
oldValue- theold value. May benull.- See Also:
-
fireChange
Fires a defaultvalue changeevent.- Parameters:
change- thechanged value.- See Also:
-
fireEvent
- Overrides:
fireEventin classAbstractEventSender<ObservableEvent<V>,ObservableEventListener<? super V>>
-
fireEventFor
- Type Parameters:
T- type of the observable value.- Parameters:
observable- theAbstractObservableValuewhere to invokefireEvent(ObservableEvent)(if prevented due to visibility issues).event- theObservableEventto send.
-
fireEventFor
- Parameters:
observable- theAbstractObservableValuewhere to invokefireEvent()(if prevented due to visibility issues).
-
invalidate
protected void invalidate()Invalidates this observable in case it's value is computed. -
toString
-
toString
- Specified by:
toStringin interfaceObservableValue<V>- Parameters:
sb- theStringBuilderwhere to append the details of this property fortoString()-Representation.
-