Class PropertyBase<T,K>
- Direct Known Subclasses:
CollectionProperty, MapProperty, Property
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPropertyBase(String name) All properties must have a nameprotectedPropertyBase(String name, Class genericType) All properties must have a name, a generic type is helpful -
Method Summary
Modifier and TypeMethodDescriptionvoidFires a notification that a property value changed to the given listenerstatic voidbindGlobalGetListener(PropertyChangeListener listener) Binds an event callback for get calls and property readsstatic voidbindGlobalSetListener(PropertyChangeListener listener) Binds an event callback for set calls and property mutationbooleanCompares this property to another propertyprotected voidDelivers the property change event to listeners if applicablegetClientProperty(String key) Returns the client property set to this property nameReturns the generic type of this property if it is known or nullgetLabel()The label of the property defaults to its name but can be changed to anythinggetName()The property name is immutable and can't be changed after creation it should match the parent field name by conventioninthashCode()voidputClientProperty(String key, Object o) Places a property that will apply statically to all instances of this propertyvoidRemoves the property change listener from the list of listenersvoidThe label of the property defaults to its name but can be changed to anything, it can be used when binding a property to UI elementsvoidThis method will work when invoked from a propertyChanged callback and should be similar toremovePropertyChangeListener(this).toString()Default toString that provides easier debug informationprotected final voidvalidateCollectionType(Class elementType) Validates that the collection type is valid and throws an exception otherwise
-
Constructor Details
-
PropertyBase
All properties must have a name
Parameters
name: the name of the property
-
PropertyBase
-
-
Method Details
-
bindGlobalSetListener
Binds an event callback for set calls and property mutation
Parameters
listener: will be invoked whenever any mutable property is changed
Throws
RuntimeException: if a set listener is already bound, there can be only one per application
Deprecated
Usage of this method isn't recommended, it's designed for internal use
-
bindGlobalGetListener
Binds an event callback for get calls and property reads
Parameters
listener: will be invoked whenever any property is read
Throws
RuntimeException: if a get listener is already bound, there can be only one per application
Deprecated
Usage of this method isn't recommended, it's designed for internal use
-
getName
The property name is immutable and can't be changed after creation it should match the parent field name by convention
Returns
the property name;
-
firePropertyChanged
protected void firePropertyChanged()Delivers the property change event to listeners if applicable -
stopListening
public void stopListening()This method will work when invoked from a propertyChanged callback and should be similar toremovePropertyChangeListener(this). It's useful for lambda's wherethismeans the base class and not the listener soremovePropertyChangeListener(this)won't do what we want unless we convert to an inner class -
addChangeListener
Fires a notification that a property value changed to the given listener
Parameters
pl: the listener
-
removeChangeListener
Removes the property change listener from the list of listeners
Parameters
pl: the change listener
-
putClientProperty
-
getClientProperty
-
equals
-
hashCode
-
toString
-
getGenericType
Returns the generic type of this property if it is known or null
Returns
the generic type
-
getLabel
The label of the property defaults to its name but can be changed to anything
Returns
the label for the property
-
setLabel
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
Parameters
label: the new label value
-
validateCollectionType
Validates that the collection type is valid and throws an exception otherwise
Parameters
elementType: the generic type of the collection
-