Package org.jdesktop.beansbinding
Class Property<S,V>
- java.lang.Object
-
- org.jdesktop.beansbinding.Property<S,V>
-
- Type Parameters:
S
- the type of source object that thisProperty
operates onV
- the type of value that thisProperty
represents
- Direct Known Subclasses:
ObjectProperty
,PropertyHelper
public abstract class Property<S,V> extends java.lang.Object
Property
defines a uniform way to access the value of a property. A typicalProperty
implemention allows you to create an immutable representation of a way to derive some property from a source object. As such, all methods of this class take a source object as an argument.A
Property
implementation may, however, be designed such that theProperty
itself is a mutable thing that stores a property value. In such a case, theProperty
implementation may ignore the source object.Property
implementations should clearly document their behavior in this regard.You can listen for changes in the state of a
Property
by registeringPropertyStateListeners
on theProperty
.
-
-
Constructor Summary
Constructors Constructor Description Property()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract void
addPropertyStateListener(S source, PropertyStateListener listener)
Adds aPropertyStateListener
to be notified when the state of theProperty
changes with respect to the given source.abstract PropertyStateListener[]
getPropertyStateListeners(S source)
Returns an arry containing the listeners registered for the given source.abstract V
getValue(S source)
Returns the value of thisProperty
for the given source.abstract java.lang.Class<? extends V>
getWriteType(S source)
Returns the type of object that is suitable for setting as the value of thisProperty
by calls tosetValue
.abstract boolean
isReadable(S source)
Returns whether or not theProperty
is readable for the given source.abstract boolean
isWriteable(S source)
Returns whether or not theProperty
is writeable for the given source.abstract void
removePropertyStateListener(S source, PropertyStateListener listener)
Removes aPropertyStateListener
for the given source.abstract void
setValue(S source, V value)
Sets the value of thisProperty
for the given source.
-
-
-
Method Detail
-
getWriteType
public abstract java.lang.Class<? extends V> getWriteType(S source)
Returns the type of object that is suitable for setting as the value of thisProperty
by calls tosetValue
.- Parameters:
source
- the source object on which to operate- Returns:
- the type of object suitable for setting as the value
- Throws:
java.lang.UnsupportedOperationException
- if theProperty
is not writeable for the given source- See Also:
setValue(S, V)
,isWriteable(S)
-
getValue
public abstract V getValue(S source)
Returns the value of thisProperty
for the given source.- Parameters:
source
- the source object on which to operate- Returns:
- the value of this
Property
for the given source - Throws:
java.lang.UnsupportedOperationException
- if theProperty
is not readable for the given source- See Also:
isReadable(S)
-
setValue
public abstract void setValue(S source, V value)
Sets the value of thisProperty
for the given source.- Parameters:
source
- the source object on which to operatevalue
- the new value for theProperty
- Throws:
java.lang.UnsupportedOperationException
- if theProperty
is not writeable for the given source- See Also:
isWriteable(S)
,getWriteType(S)
-
isReadable
public abstract boolean isReadable(S source)
Returns whether or not theProperty
is readable for the given source.- Parameters:
source
- the source object on which to operate- Returns:
- whether or not the
Property
is readable for the given source. - See Also:
isWriteable(S)
-
isWriteable
public abstract boolean isWriteable(S source)
Returns whether or not theProperty
is writeable for the given source.- Parameters:
source
- the source object on which to operate- Returns:
- whether or not the
Property
is writeable for the given source. - See Also:
isReadable(S)
-
addPropertyStateListener
public abstract void addPropertyStateListener(S source, PropertyStateListener listener)
Adds aPropertyStateListener
to be notified when the state of theProperty
changes with respect to the given source. Does nothing if the listener isnull
. If a listener is added more than once, notifications are sent to that listener once for every time that it has been added. The ordering of listener notification is unspecified.- Parameters:
source
- the source object on which to operatelistener
- the listener to be notified
-
removePropertyStateListener
public abstract void removePropertyStateListener(S source, PropertyStateListener listener)
Removes aPropertyStateListener
for the given source. Does nothing if the listener isnull
or is not one of those registered for this source object. If the listener being removed was registered more than once, only one occurrence of the listener is removed from the list of listeners. The ordering of listener notification is unspecified.- Parameters:
source
- the source object on which to operatelistener
- the listener to be removed- See Also:
addPropertyStateListener(S, org.jdesktop.beansbinding.PropertyStateListener)
-
getPropertyStateListeners
public abstract PropertyStateListener[] getPropertyStateListeners(S source)
Returns an arry containing the listeners registered for the given source. Order is undefined. Returns an empty array if there are no listeners.- Parameters:
source
- the source object on which to operate- Returns:
- the set of listeners registered for the given source
- See Also:
addPropertyStateListener(S, org.jdesktop.beansbinding.PropertyStateListener)
-
-