- 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 void
bind(ObservableValue<?>... observables)
Start observing the dependencies for changes.void
dispose()
Called if thisExpression
will not be used anymore and any references can be removed.V
get()
protected void
invalidate()
Invalidates this observable in case it's value is computed.protected boolean
isValid()
void
toString(StringBuilder sb)
protected void
unbind(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
- theSupplier
to compute thevalue
.dependencies
- theObservableValue
s theexpression
depends 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:Expression
Called if thisExpression
will not be used anymore and any references can be removed. AnyObservableEventListener
added
to dependentObservableValue
s will beremoved
.- Specified by:
dispose
in interfaceExpression<V>
-
get
public V get()
-
invalidate
protected final void invalidate()
Description copied from class:AbstractObservableValue
Invalidates this observable in case it's value is computed.- Overrides:
invalidate
in classAbstractObservableValue<V>
-
isValid
protected final boolean isValid()
- Returns:
true
if the cachedvalue
is still valid,false
otherwise (re-calculation required).
-
toString
public void toString(StringBuilder sb)
- Specified by:
toString
in interfaceObservableValue<V>
- Overrides:
toString
in classAbstractObservableValue<V>
- Parameters:
sb
- theStringBuilder
where to append the details of this property forAbstractObservableValue.toString()
-Representation.
-
-