-
Notifications
You must be signed in to change notification settings - Fork 5
Attribute Value Change Handling
Calls to the PmAttr methods setValue()
and setValueAsString()
trigger a value change operation (if the attribute is enabled).
pm4j offers some support to control value changes and to trigger other changes in relation to a value change.
Attribue specific value change control may be implemented by overriding the following methods:
-
boolean beforeValueChange(oldValue, newValue)
and -
void afterValueChange(oldValue, newValue)
(TODO: Link to JavaDoc)
The implementation of beforeValueChange()
may prevent the value change by returning false
.
A PmAttrValueChangeDecorator may be used to define value change logic that should be applied for multiple attributes.
It may also be used to add some logic an attribute provided by another PM-class or module.
A decorator may be added to the attribute value changed processing by calling:
PmEventApi#addValueChangeDecorator(pmAttr, decorator)
The following unit test may be used as an example for attribue value change handling: