Module stasgora.observetree
Package io.github.stasgora.observetree
Class SettableObservable<T extends Observable>
- java.lang.Object
-
- io.github.stasgora.observetree.Observable
-
- io.github.stasgora.observetree.SettableProperty<T>
-
- io.github.stasgora.observetree.SettableObservable<T>
-
- Type Parameters:
T
- the type of the actual observable data type. Must extend fromObservable
- All Implemented Interfaces:
Serializable
public class SettableObservable<T extends Observable> extends SettableProperty<T>
Extends the functionality of theSettableProperty
forSettableProperty.modelValue
extendingObservable
. Maintains a persistent set ofSettableProperty.modelValue
listeners that are copied over whenever a newSettableProperty.modelValue
is set. Parents of thisSettableProperty
automatically become parents of it'sSettableProperty.modelValue
.- Author:
- Stanisław Góra
- See Also:
SettableProperty
, Serialized Form
-
-
Field Summary
-
Fields inherited from class io.github.stasgora.observetree.SettableProperty
defaultValue, modelValue
-
Fields inherited from class io.github.stasgora.observetree.Observable
notificationMethod
-
-
Constructor Summary
Constructors Constructor Description SettableObservable()
SettableObservable(T modelValue)
Constructs a newSettableObservable
with the specifiedSettableProperty.modelValue
-
Method Summary
Modifier and Type Method Description protected boolean
addParent(Observable observable)
Sets the specifiedObservable
as a parent of thisSettableObservable
.boolean
addStaticListener(ChangeListener listener)
Adds the specified listener to the list of static listeners with the default priorityListenerPriority.NORMAL
(0).boolean
addStaticListener(ChangeListener listener, int priority)
Adds the specified listener to the list of static listeners with the specified priority.boolean
addStaticListener(ChangeListener listener, ListenerPriority priority)
Adds the specified listener to the list of static listeners with the specified priority.protected boolean
removeParent(Observable observable)
Removes the specifiedObservable
from parents of thisSettableObservable
.boolean
removeStaticListener(ChangeListener listener)
Removes the specified static listener from the list of listeners.void
set(T modelValue)
Sets theSettableProperty.modelValue
of thisSettableObservable
.-
Methods inherited from class io.github.stasgora.observetree.SettableProperty
get, getDefaultValue, modify, present, resetToDefaultValue, saveAsDefaultValue, setAndNotify, setDefaultValue
-
Methods inherited from class io.github.stasgora.observetree.Observable
add, add, add, addChild, addListener, addListener, addListener, addSubObservable, clearListeners, copyListeners, getChildren, getParents, isValueChanged, notifyListeners, onValueChanged, remove, removeChild, removeListener, removeSubObservable, setUnchanged
-
-
-
-
Constructor Detail
-
SettableObservable
public SettableObservable()
-
SettableObservable
public SettableObservable(T modelValue)
Constructs a newSettableObservable
with the specifiedSettableProperty.modelValue
- Parameters:
modelValue
- a value to be set
-
-
Method Detail
-
addStaticListener
public boolean addStaticListener(ChangeListener listener)
Adds the specified listener to the list of static listeners with the default priorityListenerPriority.NORMAL
(0).- Parameters:
listener
- element to be added- Returns:
true
if the listener was successfully added.false
if it was already present
-
addStaticListener
public boolean addStaticListener(ChangeListener listener, ListenerPriority priority)
Adds the specified listener to the list of static listeners with the specified priority.- Parameters:
listener
- element to be addedpriority
- priority of this listener- Returns:
true
if the listener was successfully added.false
if it was already present
-
addStaticListener
public boolean addStaticListener(ChangeListener listener, int priority)
Adds the specified listener to the list of static listeners with the specified priority.- Parameters:
listener
- element to be addedpriority
- priority of this listener- Returns:
true
if the listener was successfully added.false
if it was already present
-
removeStaticListener
public boolean removeStaticListener(ChangeListener listener)
Removes the specified static listener from the list of listeners.- Parameters:
listener
- element to be removed- Returns:
true
if the listener was successfully removed.false
if it was not found
-
addParent
protected boolean addParent(Observable observable)
Sets the specifiedObservable
as a parent of thisSettableObservable
. Note: this creates only one way binding.Observable.addSubObservable(Observable)
method is recommended for setting upObservable
relations. Method overridden to provide additional functionality.- Overrides:
addParent
in classObservable
- Parameters:
observable
- parent to be added- Returns:
true
if theObservable
was successfully added.false
if it was already present
-
removeParent
protected boolean removeParent(Observable observable)
Removes the specifiedObservable
from parents of thisSettableObservable
. Note: this removed one way binding only.Observable.removeSubObservable(Observable)
method is recommended for removingObservable
relations. Method overridden to provide additional functionality.- Overrides:
removeParent
in classObservable
- Parameters:
observable
- parent to be removed- Returns:
true
if theObservable
was successfully removed.false
if it was not found
-
set
public void set(T modelValue)
Sets theSettableProperty.modelValue
of thisSettableObservable
. Method overridden to provide additional functionality.- Overrides:
set
in classSettableProperty<T extends Observable>
- Parameters:
modelValue
- value to be set
-
-