Class AbstractObservableValue<T>
java.lang.Object
org.eclipse.core.databinding.observable.AbstractObservable
org.eclipse.core.databinding.observable.value.AbstractObservableValue<T>
- Type Parameters:
T- the type of value being observed
- All Implemented Interfaces:
IObservable, IObservableValue<T>
- Direct Known Subclasses:
AbstractVetoableValue, ComputedValue, DateAndTimeObservableValue, DuplexingObservableValue, LocalDateTimeObservableValue, SelectObservableValue, WritableValue
public abstract class AbstractObservableValue<T>
extends AbstractObservable
implements IObservableValue<T>
This class is thread safe. All state accessing methods must be invoked from
the current realm. Methods for adding and removing
listeners may be invoked from any thread.
- Since:
- 1.0
- Implementation Note:
- If methods are added to the interface which this class implements then implementations of those methods must be added to this class.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance with the default realm.AbstractObservableValue(Realm realm) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddListener(Object listenerType, IObservablesListener listener) voidaddValueChangeListener(IValueChangeListener<? super T> listener) protected Objectclone()protected abstract Tprotected voiddoSetValue(T value) Template method for setting the value of the observable.protected voidprotected voidfireEvent(ObservableEvent event) protected voidfireValueChange(ValueDiff<T> diff) protected voidgetRealm()final TgetValue()Returns the value.protected booleanbooleanisStale()Returns whether the state of this observable is stale and is expected to change soon.protected voidprotected voidremoveListener(Object listenerType, IObservablesListener listener) voidremoveValueChangeListener(IValueChangeListener<? super T> listener) final voidSets the value.Methods inherited from class AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, dispose, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListenerMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListenerMethods inherited from interface IObservableValue
getValueType
-
Constructor Details
-
AbstractObservableValue
public AbstractObservableValue()Constructs a new instance with the default realm. -
AbstractObservableValue
- Parameters:
realm- the realm to use; notnull
-
-
Method Details
-
addValueChangeListener
- Specified by:
addValueChangeListenerin interfaceIObservableValue<T>- Parameters:
listener- the change listener to add; notnull
-
removeValueChangeListener
- Specified by:
removeValueChangeListenerin interfaceIObservableValue<T>- Parameters:
listener- the change listener to remove; notnull
-
setValue
Description copied from interface:IObservableValueSets the value. Must be invoked in theRealmof the observable.- Specified by:
setValuein interfaceIObservableValue<T>- Parameters:
value- the value to set
-
doSetValue
Template method for setting the value of the observable. By default the method throws anUnsupportedOperationException.- Parameters:
value- the value to set
-
fireValueChange
-
getValue
Description copied from interface:IObservableValueReturns the value. Must be invoked in theRealmof the observable.- Specified by:
getValuein interfaceIObservableValue<T>- Returns:
- the current value
-
doGetValue
-
isStale
public boolean isStale()Description copied from interface:IObservableReturns whether the state of this observable is stale and is expected to change soon. A non-stale observable that becomes stale will notify its stale listeners. A stale object that becomes non-stale does so by changing its state and notifying its change listeners, it does not notify its stale listeners about becoming non-stale. Clients that do not expect asynchronous changes may ignore staleness of observable objects.- Specified by:
isStalein interfaceIObservable- Returns:
- true if this observable's state is stale and will change soon.
-
fireChange
protected void fireChange()- Overrides:
fireChangein classAbstractObservable
-
addListener
- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to add; notnull
-
removeListener
- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to remove; notnull
-
hasListeners
protected boolean hasListeners() -
fireEvent
-
firstListenerAdded
protected void firstListenerAdded() -
lastListenerRemoved
protected void lastListenerRemoved() -
getRealm
- Returns:
- Returns the realm.
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-