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.String
PROP_VALUE
-
Constructor Summary
Constructors Constructor Description BoundProperty()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(ChangingSource<T> source)
Binds this property to aChangingSource
.T
get()
Returns the value of this object.static <T> BoundProperty<T>
of(T value)
Creates a newBoundProperty
with the given initial value.void
set(T value)
Sets a new value to this object.void
unbindAll()
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 newBoundProperty
with 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:
set
in interfaceChangeable<T>
- Parameters:
value
- the new value
-
get
public T get()
Returns the value of this object.- Specified by:
get
in 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 aChangeable
binding 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:
unbindAll
in interfaceChangingSource<T>
-
-