public class PropertyBase<T,K> extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
PropertyBase(String name)
All properties must have a name
|
protected |
PropertyBase(String name,
Class genericType)
All properties must have a name, a generic type is helpful
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(PropertyChangeListener<T,K> pl)
Fires a notification that a property value changed to the given listener
|
static void |
bindGlobalGetListener(PropertyChangeListener listener)
Deprecated.
Usage of this method isn't recommended, it's designed for internal use
|
static void |
bindGlobalSetListener(PropertyChangeListener listener)
Deprecated.
Usage of this method isn't recommended, it's designed for internal use
|
boolean |
equals(Object obj)
Compares this property to another property
|
protected void |
firePropertyChanged()
Delivers the property change event to listeners if applicable
|
Object |
getClientProperty(String key)
Returns the client property set to this property name
|
Class |
getGenericType()
Returns the generic type of this property if it is known or null
|
String |
getLabel()
The label of the property defaults to its name but can be changed to anything
|
String |
getName()
The property name is immutable and can't be changed after creation it should match the parent field name by convention
|
void |
putClientProperty(String key,
Object o)
Places a property that will apply statically to all instances of this property
|
void |
removeChangeListener(PropertyChangeListener<T,K> pl)
Removes the property change listener from the list of listeners
|
void |
setLabel(String label)
The label of the property defaults to its name but can be changed to anything, it can be used
when binding a property to UI elements
|
void |
stopListening()
This method will work when invoked from a propertyChanged callback and should be similar to
removePropertyChangeListener(this). |
String |
toString()
Default toString that provides easier debug information
|
protected void |
validateCollectionType(Class elementType)
Validates that the collection type is valid and throws an exception otherwise
|
protected PropertyBase(String name)
name - the name of the propertypublic static void bindGlobalSetListener(PropertyChangeListener listener)
listener - will be invoked whenever any mutable property is changedRuntimeException - if a set listener is already bound, there can be only one per applicationpublic static void bindGlobalGetListener(PropertyChangeListener listener)
listener - will be invoked whenever any property is readRuntimeException - if a get listener is already bound, there can be only one per applicationpublic String getName()
protected void firePropertyChanged()
public void stopListening()
removePropertyChangeListener(this). It's useful for lambda's where this
means the base class and not the listener so removePropertyChangeListener(this)
won't do what we want unless we convert to an inner classpublic void addChangeListener(PropertyChangeListener<T,K> pl)
pl - the listenerpublic void removeChangeListener(PropertyChangeListener<T,K> pl)
pl - the change listenerpublic void putClientProperty(String key, Object o)
key - the key to puto - the value objectpublic Object getClientProperty(String key)
key - the key of the propertypublic boolean equals(Object obj)
public String toString()
public Class getGenericType()
public void setLabel(String label)
label - the new label valuepublic String getLabel()
protected final void validateCollectionType(Class elementType)
elementType - the generic type of the collection