|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectch.elca.el4j.util.observer.impl.AbstractObservableValue<T>
ch.elca.el4j.util.observer.impl.LiveValue<T>
T
- see supertypepublic class LiveValue<T>
A LiveValue is a derived value that stays up to date by itself.
A LiveValue is defined by a method computing it. The method is usually
implemented in a Computable
and given to LiveValue's public
constructor. Alternatively, the method may also be provided by overriding
is()
. In that case, you may not assume that the subclass'
constructor is invoked before is()
is.
A LiveValue is an ObservableValue. Therefore, it is possible to build
directed acyclic graphs (and thus trees) of LiveValues. For
obvious reasons, cyclic dependencies are not permitted; detection of one
results in a CyclicDependencyException
to be thrown.
This class is thread safe.
If the live value only
depends on values of type ObservableValue (which it obtains by invoking
ObservableValue.get()
), the live value will keep itself up to date
by itself. Otherwise, updates must be requested manually using
revise()
.
LiveValueFactory
Nested Class Summary | |
---|---|
protected static class |
LiveValue.Currency
a cached value's degree of currency. |
Constructor Summary | |
---|---|
protected |
LiveValue()
creates this live value. |
|
LiveValue(Computable<T> computation)
creates the live value defined by the supplied Computable . |
Method Summary | |
---|---|
void |
changed(Object newvalue)
not intended for public use. |
T |
get()
. |
protected T |
is()
The computation represented by this live value. |
void |
notified()
not intended for public use. |
void |
revise()
revise the result cached by this live value, i.e. ensure it is still correct.Invoke this method if non-observable input values may have changed. |
String |
toString()
returns a textual description of this live value. |
Methods inherited from class ch.elca.el4j.util.observer.impl.AbstractObservableValue |
---|
equal, set, subscribe, subscribeSilently, unsubscribe |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected LiveValue()
is()
and be prepared to receive calls to it before their constructor is
invoked. (This restriction can be circumvented by initializing the
live value in a separate Computable
before passing it to this
class' other constructor)
public LiveValue(Computable<T> computation)
Computable
.
Method Detail |
---|
protected T is()
public void revise()
public T get()
get
in interface ObservableValue<T>
get
in class AbstractObservableValue<T>
public void changed(Object newvalue)
changed
in interface ValueObserver<Object>
newvalue
- the new referencepublic String toString()
toString
in class Object
public void notified()
notified
in interface InquisitiveValueObserver<Object>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |