Class Attribute<T extends Number>
- Type Parameters:
T- the type of the attribute value, which must be a Number
- All Implemented Interfaces:
IAttribute<T>, Serializable
- Direct Known Subclasses:
RangeAttribute
Represents an attribute with a base value and a list of modifiers. The attribute value can be modified by adding or removing modifiers.
This class is XML-serializable via JAXB. The base value is written as an XML attribute
named value; runtime-only data (such as registered modifiers and property change support)
is marked transient and is not part of the serialized form.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PropertyChangeSupportThe support object used to manage and notify property change listeners.protected TThe base value of the attribute. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PropertyChangeListener listener) Adds a property change listener to the attribute.voidaddModifier(AttributeModifier<T> modifier) Adds a modifier to the attribute and fires a property change event.Gets the current value of the attribute, computed by applying all active modifications to the base value.Gets the list of all property modifiers applied to the attribute.getValue()Gets the base value of the attribute.voidmodify(AttributeModifier<T> modifier) Modifies the current value of the attribute using the specified property modifier.voidmodify(Modification modification, double value) Modifies the current value of the attribute using a new property modifier created with the specified modification and value.voidremoveListener(PropertyChangeListener listener) Removes a property change listener from the attribute.voidremoveModifier(AttributeModifier<T> modifier) Removes a modifier from the attribute and fires a property change event.voidSets the base value of the attribute and fires a property change event.toString()Returns a string representation of the current value of the attribute.
-
Field Details
-
support
The support object used to manage and notify property change listeners. It allows other components to listen for changes to the properties of this object. -
value
The base value of the attribute. This value represents the unmodified state of the attribute before any modifiers are applied. It is serialized as the
valueXML attribute.Subclasses such as
RangeAttributethat do not want to persist a base value can suppress serialization at runtime via JAXBbeforeMarshal/afterMarshalcallbacks.
-
-
Constructor Details
-
Attribute
public Attribute()Default no-argument constructor. -
Attribute
Constructs a new Attribute with the specified initial value.- Parameters:
initialValue- the initial value of the attribute
-
-
Method Details
-
getValue
Gets the base value of the attribute.- Specified by:
getValuein interfaceIAttribute<T extends Number>- Returns:
- the base value of the attribute
-
getModifiedValue
Gets the current value of the attribute, computed by applying all active modifications to the base value.- Specified by:
getModifiedValuein interfaceIAttribute<T extends Number>- Returns:
- the current value
-
setValue
Sets the base value of the attribute and fires a property change event.- Specified by:
setValuein interfaceIAttribute<T extends Number>- Parameters:
newValue- the new base value of the attribute
-
addListener
Adds a property change listener to the attribute.- Specified by:
addListenerin interfaceIAttribute<T extends Number>- Parameters:
listener- the property change listener to be added
-
removeListener
Removes a property change listener from the attribute.- Specified by:
removeListenerin interfaceIAttribute<T extends Number>- Parameters:
listener- the property change listener to be removed
-
addModifier
Adds a modifier to the attribute and fires a property change event. If the modifier is already present, it will not be added again.- Specified by:
addModifierin interfaceIAttribute<T extends Number>- Parameters:
modifier- the property modifier to be added
-
removeModifier
Removes a modifier from the attribute and fires a property change event. If the modifier is not present, no action is taken.- Specified by:
removeModifierin interfaceIAttribute<T extends Number>- Parameters:
modifier- the property modifier to be removed
-
getModifiers
Gets the list of all property modifiers applied to the attribute.- Returns:
- the list of property modifiers
-
modify
Modifies the current value of the attribute using the specified property modifier.- Specified by:
modifyin interfaceIAttribute<T extends Number>- Parameters:
modifier- the property modifier to apply
-
modify
Modifies the current value of the attribute using a new property modifier created with the specified modification and value.- Specified by:
modifyin interfaceIAttribute<T extends Number>- Parameters:
modification- the type of modification to applyvalue- the value to use for the modification
-
toString
-