Package it.tidalwave.role.ui
Class BoundProperty<T>
- java.lang.Object
-
- it.tidalwave.role.ui.BoundProperty<T>
-
- All Implemented Interfaces:
Changeable<T>,ChangingSource<T>
public class BoundProperty<T> extends java.lang.Object implements ChangingSource<T>, Changeable<T>
- Author:
- Fabrizio Giudici
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROP_VALUE
-
Constructor Summary
Constructors Constructor Description BoundProperty()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbind(ChangingSource<T> source)Binds this property to aChangingSource.Tget()Returns the value of this object.static <T> BoundProperty<T>of(T value)Creates a newBoundPropertywith the given initial value.voidset(T value)Sets a new value to this object.voidunbindAll()Removes all the bindings of this object.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.tidalwave.role.ui.ChangingSource
addPropertyChangeListener, getPropertyChangeListeners, removePropertyChangeListener
-
-
-
-
Field Detail
-
PROP_VALUE
public static final java.lang.String PROP_VALUE
- See Also:
- Constant Field Values
-
-
Method Detail
-
of
@Nonnull public static <T> BoundProperty<T> of(@Nonnull T value)
Creates a newBoundPropertywith the given initial value.- Type Parameters:
T- the type of the property- Parameters:
value- the initial value- Returns:
- the property
- Since:
- 3.2-ALPHA-2
-
set
public void set(T value)
Sets a new value to this object. This method fires a property change event associated toPROP_VALUE.- Specified by:
setin interfaceChangeable<T>- Parameters:
value- the new value
-
get
public T get()
Returns the value of this object.- Specified by:
getin interfaceChangingSource<T>- Returns:
- the value
-
bind
public void bind(@Nonnull ChangingSource<T> source)Binds this property to aChangingSource. Every change in the value of the source will be synchronized to the value of this property. If the source is aChangeablebinding will be bidirectional, that is the object will be set to the current value of this property and will be kept in sync.- Parameters:
source- the source
-
unbindAll
public void unbindAll()
Removes all the bindings of this object.- Specified by:
unbindAllin interfaceChangingSource<T>
-
-