Class WritableValue<T>
java.lang.Object
org.eclipse.core.databinding.observable.AbstractObservable
org.eclipse.core.databinding.observable.value.AbstractObservableValue<T>
org.eclipse.core.databinding.observable.value.WritableValue<T>
- Type Parameters:
T
- the type of value being observed
- All Implemented Interfaces:
IObservable
,IObservableValue<T>
Mutable (writable) implementation of
IObservableValue
that will
maintain a value and fire change events when the value changes.
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
-
Constructor Summary
ConstructorDescriptionConstructs a new instance with the default realm, anull
value type, and anull
value.WritableValue
(Realm realm) Constructs a new instance with the providedrealm
, anull
value type, and anull
initial value.WritableValue
(Realm realm, T initialValue, Object valueType) Constructs a new instance.WritableValue
(T initialValue, Object valueType) Constructs a new instance with the default realm. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addListener
(Object listenerType, IObservablesListener listener) protected Object
clone()
void
doSetValue
(T value) Template method for setting the value of the observable.protected void
fireEvent
(ObservableEvent event) protected void
getRealm()
The value type of this observable value, ornull
if this observable value is untyped.protected boolean
protected void
protected void
removeListener
(Object listenerType, IObservablesListener listener) static <T2> WritableValue<T2>
withValueType
(Object elementType) Methods inherited from class org.eclipse.core.databinding.observable.value.AbstractObservableValue
addValueChangeListener, fireChange, fireValueChange, getValue, isStale, removeValueChangeListener, setValue
Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, dispose, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
Constructor Details
-
WritableValue
public WritableValue()Constructs a new instance with the default realm, anull
value type, and anull
value. -
WritableValue
Constructs a new instance with the default realm.- Parameters:
initialValue
- can benull
valueType
- can benull
-
WritableValue
Constructs a new instance with the providedrealm
, anull
value type, and anull
initial value.- Parameters:
realm
- the realm
-
WritableValue
Constructs a new instance.- Parameters:
realm
- the realminitialValue
- can benull
valueType
- can benull
-
-
Method Details
-
doGetValue
- Specified by:
doGetValue
in classAbstractObservableValue<T>
-
doSetValue
Description copied from class:AbstractObservableValue
Template method for setting the value of the observable. By default the method throws anUnsupportedOperationException
.- Overrides:
doSetValue
in classAbstractObservableValue<T>
- Parameters:
value
- The value to set.
-
getValueType
Description copied from interface:IObservableValue
The value type of this observable value, ornull
if this observable value is untyped.- Returns:
- the value type, or
null
-
withValueType
- Type Parameters:
T2
- the type of observed value of the created instance- Parameters:
elementType
- can benull
- Returns:
- new instance with the default realm and a value of
null
-
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:
clone
in classObject
- Throws:
CloneNotSupportedException
-