ch.elca.el4j.util.observer.impl
Class AbstractObservableValue<T>

java.lang.Object
  extended by ch.elca.el4j.util.observer.impl.AbstractObservableValue<T>
Type Parameters:
T - see supertype.
All Implemented Interfaces:
ObservableValue<T>
Direct Known Subclasses:
LiveValue, SettableObservableValue

public abstract class AbstractObservableValue<T>
extends Object
implements ObservableValue<T>

Abstract ObservableValue featuring value and observer storage as well as notification.

Author:
Adrian Moos (AMS)
File-location:
AbstractObservableValue
Last check-in date:
2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) by swismer for revision 3873

Constructor Summary
protected AbstractObservableValue()
          creates a new ObservableValue.
  AbstractObservableValue(T initialReference)
          creates a new ObservableValue.
 
Method Summary
protected  boolean equal(T a, T b)
          defines when two references are considered equal.
 T get()
          
protected  void set(T newValue)
          updates this observer's current value and announces the change.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractObservableValue

protected AbstractObservableValue()
creates a new ObservableValue. Subclasses must invoke set(Object) to set the initial reference before get() is invoked.


AbstractObservableValue

public AbstractObservableValue(T initialReference)
creates a new ObservableValue.

Parameters:
initialReference - the observable's initial value
Method Detail

subscribeSilently

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

Specified by:
subscribeSilently in interface ObservableValue<T>
Parameters:
o - the object to receive change notifications

subscribe

public 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.

Specified by:
subscribe in interface ObservableValue<T>
Parameters:
o - the object to receive change notifications

unsubscribe

public 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.

Specified by:
unsubscribe in interface ObservableValue<T>
Parameters:
o - the object no longer to receive change notifications

set

protected void set(T newValue)
updates this observer's current value and announces the change.


get

public T get()
      throws IllegalStateException

Specified by:
get in interface ObservableValue<T>
Returns:
this observable's current value
Throws:
IllegalStateException - if the observed reference does not exist yet.

equal

protected boolean equal(T a,
                        T b)
defines when two references are considered equal.



Copyright © 2005-2011 ELCA. All Rights Reserved.