Package io.github.mmm.value.observable
Class AbstractWritableObservableValue<V>
java.lang.Object
io.github.mmm.event.AbstractEventSource<ObservableEvent<V>,ObservableEventListener<? super V>>
io.github.mmm.value.observable.AbstractObservableValue<V>
io.github.mmm.value.observable.AbstractWritableObservableValue<V>
- Type Parameters:
V- type of the observablevalue.
- All Implemented Interfaces:
EventSource<ObservableEvent<V>,,ObservableEventListener<? super V>> ObservableValue<V>,WritableObservableValue<V>,ReadableValue<V>,WritableValue<V>,Supplier<V>
public abstract class AbstractWritableObservableValue<V>
extends AbstractObservableValue<V>
implements WritableObservableValue<V>
Abstract base implementation of
WritableObservableValue that handles bindings.- Since:
- 1.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbindInternal(ObservableValue<? extends V> observable) Internal method ofbindOneWay(ObservableValue).voidbindOneWay(ObservableValue<? extends V> observable) Creates a unidirection binding for this object.
ATTENTION:
An unidirectional binding is very strict.voidbindTwoWay(WritableObservableValue<V> other) Create a bidirectional binding between this object and the given one.protected abstract VdoGet()protected abstract voidget()booleanprotected booleanisValueEqual(V newValue, V oldValue) Null-safe check if twovaluesare considered equal (unchanged).protected voidvoidprotected voidsetWithChange(V oldValue, V value) Internal method called fromset(Object)if the value actually changed.voidRemoves theunidirectional bindingfrom this object.voidunbindTwoWay(WritableObservableValue<V> other) Removes abidirectional bindingbetween this object and the given one.Methods inherited from class io.github.mmm.value.observable.AbstractObservableValue
addListener, fireChange, fireEvent, fireEvent, fireEventFor, fireEventFor, fireEventWithOldValue, hasChangeAwareListeners, invalidate, removeListener, toString, toStringMethods inherited from class io.github.mmm.event.AbstractEventSource
getEventAdapter, hasListenersMethods 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, addWeakListener, removeListenerMethods inherited from interface io.github.mmm.value.observable.ObservableValue
toStringMethods inherited from interface io.github.mmm.value.ReadableValue
getSafe
-
Constructor Details
-
AbstractWritableObservableValue
public AbstractWritableObservableValue()
-
-
Method Details
-
get
-
doGet
- Returns:
- the internal
value.
-
bindOneWay
Description copied from interface:WritableObservableValueCreates a unidirection binding for this object.
ATTENTION:
An unidirectional binding is very strict. It makes this object to appear exactly as theObservableValueit is bound to. After creating the unidirectional binding, calls toWritableValue.set(Object)will fail. This is very different to anbidirectional binding.- Specified by:
bindOneWayin interfaceWritableObservableValue<V>- Parameters:
observable- theObservableValuethis object should be bound to.- See Also:
-
bindInternal
Internal method ofbindOneWay(ObservableValue). Do not call.- Parameters:
observable- theObservableValueto bind.- See Also:
-
unbindOneWay
public void unbindOneWay()Description copied from interface:WritableObservableValueRemoves theunidirectional bindingfrom this object. If this object is notbound, this method has no effect.- Specified by:
unbindOneWayin interfaceWritableObservableValue<V>- See Also:
-
isBoundOneWay
public boolean isBoundOneWay()- Specified by:
isBoundOneWayin interfaceWritableObservableValue<V>- Returns:
trueif this object isbound,falseotherwise.- See Also:
-
bindTwoWay
Description copied from interface:WritableObservableValueCreate a bidirectional binding between this object and the given one. After a bidirectional binding,WritableValue.set(Object)on this object will propagate its value to the bound one and vice versa. Bidirectional bindings exists independently ofunidirectional bindings. However, it is bad practice to combine both. It is possible to have multiple bidirectional bindings for the same object.- Specified by:
bindTwoWayin interfaceWritableObservableValue<V>- Parameters:
other- the otherWritableObservableValueto bind bidirectional.- See Also:
-
unbindTwoWay
Description copied from interface:WritableObservableValueRemoves abidirectional bindingbetween this object and the given one. If no bidirectional binding between these objects exists, this method has no effect. It is possible tounbindin inverse order. So to unbind twobidirectional boundobjects it does not matter if you callunbindBidirectionalon the first with the second as argument or vice versa.- Specified by:
unbindTwoWayin interfaceWritableObservableValue<V>- Parameters:
other- the otherWritableObservableValueto unbind bidirectional.- See Also:
-
set
- Specified by:
setin interfaceWritableValue<V>
-
isValueEqual
Null-safe check if twovaluesare considered equal (unchanged).- Parameters:
newValue- the new value.oldValue- the old value.- Returns:
trueif equal (unchanged),falseotherwise (changed),
-
setWithChange
Internal method called fromset(Object)if the value actually changed.- Parameters:
oldValue- the old value.value- the new value.
-
requireWritable
- Throws:
IllegalStateException- if this property is not writable.
-
doSet
- Parameters:
newValue- the newvalueto set.- See Also:
-