ch.elca.el4j.util.observer
Interface ObservableValue<T>

Type Parameters:
T - the type of object held.
All Known Implementing Classes:
AbstractObservableValue, LiveValue, SettableObservableValue

public interface ObservableValue<T>

Instances of ObservableValue encapsulate an observable reference of type T. The reference may not exist yet, be null, or point to an allocated object.

ObservableValues should be accessed by at most one thread at a time. Reentrant calls are permitted.

InquisitiveValueObservers are supported. They can be subscribed like ordinary ValueObservers.

Note to implementors: If LiveValues may depend on instances of your class, you must invoke LiveValue.observableGetterInterceptor() whenever get() may have been invoked from a LiveValue. (We do not require this by static means to avoid loading LiveValue regardless of whether it is used.)

Author:
Adrian Moos (AMS)
See Also:
"Observer Pattern", ValueObserver
File-location:
ObservableValue
Last check-in date:
2009-08-04 15:22:05 +0200 (Di, 04. Aug 2009) by swismer for revision 3881

Method Summary
 T get()
           
 void subscribe(ValueObserver<? super T> o)
          subscribe to this observable's change notifications.
 void subscribeSilently(ValueObserver<? super T> o)
          subscribe to this observable's change notifications without getting an initial change notification.
 void unsubscribe(ValueObserver<? super T> o)
          unsubscribes from this observable's change notifications, i.e. no change notification will be sent anymore.
 

Method Detail

subscribeSilently

void subscribeSilently(ValueObserver<? super T> o)
subscribe to this observable's change notifications without getting an initial change notification.

Parameters:
o - the object to receive change notifications

subscribe

void subscribe(ValueObserver<? super T> o)
subscribe to this observable's change notifications. The new observer receives an initial notification if the observed reference already exists.

Parameters:
o - the object to receive change notifications

unsubscribe

void unsubscribe(ValueObserver<? super T> o)
unsubscribes from this observable's change notifications, i.e. no change notification will be sent anymore. Has no effect if o is not subscribed.

Parameters:
o - the object no longer to receive change notifications

get

T get()
      throws IllegalStateException
Returns:
this observable's current value
Throws:
IllegalStateException - if the observed reference does not exist yet.


Copyright © 2005-2011 ELCA. All Rights Reserved.