T
- The type of the expression.public abstract class PassiveExpression<T> extends java.lang.Object implements Expression<T>
Constructor and Description |
---|
PassiveExpression(java.util.Collection<? extends Expression<?>> dependencies) |
PassiveExpression(Expression<?>... dependencies) |
Modifier and Type | Method and Description |
---|---|
protected abstract T |
evaluate() |
T |
getValue()
This should always return the correct current value for this Expression.
|
Observable<Expression<? extends T>> |
invalidations() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
anonymize, decoupleValue, immutable, over, over
public PassiveExpression(java.util.Collection<? extends Expression<?>> dependencies)
public PassiveExpression(Expression<?>... dependencies)
public Observable<Expression<? extends T>> invalidations()
invalidations
in interface Expression<T>
public final T getValue()
Expression
Expression
, i.e. it should be either an immutable class, a const
reference, or a copy of the underlying value. This is important, but
conversely it does not mean that the return value can necessarily be
relied upon not to not mutate when this expression is updated, unless a read
lock is held.
Once a value has been returned, it is up to the implementing Expression as to
whether the value will be reliable such that it will remain the same even if
the conceptual value of this expression subsequently changes, or whether it
will update automatically with the expression. Please only rely on either
behavior if it is explicitly documented, otherwise use
Expression.decoupleValue()
if you need a persistent reference which is safe
to mutate and/or safe from external mutation.
The observers should only ever be notified of an update from the thread which
has the write lock on an Expression
, and Expression
s should
be careful to only notify observers when they are in a state where their
value can be fetched. Immediate fetch is discouraged, though. Expressions
should generally update lazily, not eagerly.
getValue
in interface Expression<T>
protected abstract T evaluate()
Expression
as derived from the dependency
Expression
s.