Class PropertyBase<T,K>
- Direct Known Subclasses:
CollectionProperty, MapProperty, Property
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPropertyBase(String name) All properties must have a nameprotectedPropertyBase(String name, java.lang.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 mutationbooleanequals(java.lang.Object obj) Compares this property to another propertyprotected voidDelivers the property change event to listeners if applicablejava.lang.ObjectgetClientProperty(String key) Returns the client property set to this property namejava.lang.ClassReturns 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, java.lang.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(java.lang.Class elementType) Validates that the collection type is valid and throws an exception otherwiseMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
PropertyBase
All properties must have a name
Parameters
name: the name of the property
-
PropertyBase
All properties must have a name, a generic type is helpful
Parameters
-
name: the name of the property -
genericType: the property type to workaround issues with erasure
-
-
-
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
Places a property that will apply statically to all instances of this property
Parameters
-
key: the key to put -
o: the value object
-
-
getClientProperty
Returns the client property set to this property name
Parameters
key: the key of the property
Returns
the value that was previously placed with put client property
-
equals
public boolean equals(java.lang.Object obj) Compares this property to another property
Parameters
obj: the other property
Returns
true if they are equal in name and value
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
toString
Default toString that provides easier debug information
Returns
a formatted representation of the property for debugging
- Overrides:
toStringin classjava.lang.Object
-
getGenericType
public java.lang.Class 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
protected final void validateCollectionType(java.lang.Class elementType) Validates that the collection type is valid and throws an exception otherwise
Parameters
elementType: the generic type of the collection
-