- 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.Binding<V>
-
- Type Parameters:
V- type of the observablevalue.
- All Implemented Interfaces:
EventSource<ObservableEvent<V>,ObservableEventListener<? super V>>,Expression<V>,ObservableValue<V>,ReadableValue<V>,Supplier<V>
- Direct Known Subclasses:
BooleanBinding,InstantBinding,LocalDateBinding,LocalDateTimeBinding,LocalTimeBinding,NumberBinding,OffsetDateTimeBinding,OffsetDateTimeBinding,StringBinding,ZonedDateTimeBinding
public abstract class Binding<V> extends AbstractObservableValue<V> implements Expression<V>
- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description Binding(Supplier<? extends V> expression, ObservableValue<?>... dependencies)The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbind(ObservableValue<?>... observables)Start observing the dependencies for changes.voiddispose()Called if thisExpressionwill not be used anymore and any references can be removed.Vget()protected voidinvalidate()Invalidates this observable in case it's value is computed.protected booleanisValid()voidtoString(StringBuilder sb)protected voidunbind(ObservableValue<?>... observables)Stop observing the dependencies for changes.-
Methods inherited from class io.github.mmm.value.observable.AbstractObservableValue
addListener, fireChange, fireEvent, fireEvent, fireEventFor, fireEventFor, fireEventWithOldValue, hasChangeAwareListeners, removeListener, 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.Expression
asString, isEqualTo, isEqualTo, isNotEqualTo, isNotEqualTo, isNotNull, isNull
-
Methods inherited from interface io.github.mmm.value.ReadableValue
getSafe
-
-
-
-
Constructor Detail
-
Binding
public Binding(Supplier<? extends V> expression, ObservableValue<?>... dependencies)
The constructor.- Parameters:
expression- theSupplierto compute thevalue.dependencies- theObservableValues theexpressiondepends on.
-
-
Method Detail
-
bind
protected final void bind(ObservableValue<?>... observables)
Start observing the dependencies for changes. If the value of one of the dependencies changes, the binding is marked as invalid.- Parameters:
observables- the dependencies to observe
-
unbind
protected final void unbind(ObservableValue<?>... observables)
Stop observing the dependencies for changes.- Parameters:
observables- the dependencies to stop observing
-
dispose
public void dispose()
Description copied from interface:ExpressionCalled if thisExpressionwill not be used anymore and any references can be removed. AnyObservableEventListeneraddedto dependentObservableValues will beremoved.- Specified by:
disposein interfaceExpression<V>
-
get
public V get()
-
invalidate
protected final void invalidate()
Description copied from class:AbstractObservableValueInvalidates this observable in case it's value is computed.- Overrides:
invalidatein classAbstractObservableValue<V>
-
isValid
protected final boolean isValid()
- Returns:
trueif the cachedvalueis still valid,falseotherwise (re-calculation required).
-
toString
public void toString(StringBuilder sb)
- Specified by:
toStringin interfaceObservableValue<V>- Overrides:
toStringin classAbstractObservableValue<V>- Parameters:
sb- theStringBuilderwhere to append the details of this property forAbstractObservableValue.toString()-Representation.
-
-