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>
- Direct Known Subclasses:
Property
public abstract class AbstractWritableObservableValue<V> extends AbstractObservableValue<V> implements WritableObservableValue<V>
Abstract base implementation ofWritableObservableValuethat handles bindings.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description AbstractWritableObservableValue()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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 voiddoSet(V newValue)Vget()booleanisBoundOneWay()protected booleanisValueEqual(V newValue, V oldValue)Null-safe check if twovaluesare considered equal (unchanged).protected voidrequireWritable()voidset(V value)protected voidsetWithChange(V oldValue, V value)Internal method called fromset(Object)if the value actually changed.voidunbindOneWay()Removes 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, toString
-
Methods inherited from class io.github.mmm.event.AbstractEventSource
getEventAdapter, hasListeners
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.event.EventSource
addListener, addListener, addWeakListener, removeListener
-
Methods inherited from interface io.github.mmm.value.observable.ObservableValue
toString
-
Methods inherited from interface io.github.mmm.value.ReadableValue
getSafe
-
-
-
-
Method Detail
-
get
public V get()
-
bindOneWay
public void bindOneWay(ObservableValue<? extends V> observable)
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:
WritableObservableValue.unbindOneWay(),WritableObservableValue.isBoundOneWay()
-
bindInternal
protected void bindInternal(ObservableValue<? extends V> observable)
Internal method ofbindOneWay(ObservableValue). Do not call.- Parameters:
observable- theObservableValueto bind.- See Also:
bindOneWay(ObservableValue)
-
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:
WritableObservableValue.bindOneWay(ObservableValue)
-
isBoundOneWay
public boolean isBoundOneWay()
- Specified by:
isBoundOneWayin interfaceWritableObservableValue<V>- Returns:
trueif this object isbound,falseotherwise.- See Also:
WritableObservableValue.bindOneWay(ObservableValue)
-
bindTwoWay
public void bindTwoWay(WritableObservableValue<V> other)
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:
WritableObservableValue.unbindTwoWay(WritableObservableValue)
-
unbindTwoWay
public void unbindTwoWay(WritableObservableValue<V> other)
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:
WritableObservableValue.bindTwoWay(WritableObservableValue)
-
set
public void set(V value)
- Specified by:
setin interfaceWritableValue<V>- Parameters:
value- the newvalue.
-
isValueEqual
protected boolean isValueEqual(V newValue, V oldValue)
Null-safe check if twovaluesare considered equal (unchanged).- Parameters:
newValue- the new value.oldValue- the old value.- Returns:
trueif equal (unchanged),falseotherwise (changed),
-
setWithChange
protected void setWithChange(V oldValue, V value)
Internal method called fromset(Object)if the value actually changed.- Parameters:
oldValue- the old value.value- the new value.
-
requireWritable
protected void requireWritable() throws IllegalStateException- Throws:
IllegalStateException- if this property is not writable.
-
doSet
protected abstract void doSet(V newValue)
- Parameters:
newValue- the newvalueto set.- See Also:
set(Object)
-
-