Package io.github.mmm.value.observable
Interface ObservableEvent<V>
- Type Parameters:
V
- type of observedvalue
.
public interface ObservableEvent<V>
Event notifying about changes of an
ObservableValue
.- Since:
- 1.0.0
- See Also:
-
Method Details
-
getObservable
ObservableValue<V> getObservable()- Returns:
- the
ObservableValue
that changed and send this event.
-
getValue
V getValue()- Returns:
- the current
value
.
-
getOldValue
V getOldValue()- Returns:
- the
value
before the change. May benull
if the previous value wasnull
orthe old value is not available
.
-
hasOldValue
boolean hasOldValue()- Returns:
true
if the old value is available,false
otherwise. For advanced performance the old value is not available for dynamically computedObservableValue
s by default. It is guaranteed to be available if at least one of theregistered
ObservableEventListener
s has calledgetValue()
on the previousObservableEvent
forcing an eager evaluation.
-
getChange
<M> M getChange()- Type Parameters:
M
- type of the change.- Returns:
- the modification in case of a
value change
,null
otherwise. - See Also:
-
isChange
default boolean isChange()- Returns:
true
if thevalue
object instance itself has changed. MostObservableValue
s contain immutable value types (such asString
,Boolean
,Integer
,BigDecimal
,Instant
, etc.). However, values like e.g.Collection
are mutable and may support notifyingchanges
. Otherwise, iffalse
theobservable
itself was modified and itsvalue
has changed (or was invalidated and needs to be recalculated).- See Also:
-