-
Notifications
You must be signed in to change notification settings - Fork 5
Attribute Default Values
PmAttr's may be configured to have default values if their backing value is null.
The default value feature is intended for edit use cases.
This means: Default values will only be applied for enabled attributes.
You may pass the default value using a string.
@PmAttrCfg(defaultValue="...")
The annotation uses the type specific string format as used for PmAttr.setValueAsString().
In case of enums it's the enum literal name, in case of a boolean attribute 'true' or 'false'...
You may override the method getDefaultValueImpl() to provide a java based default value logic. An example
PmAttrBoolean myAttr = new PmAttrBooleanImpl(this) { protected Boolean getDefaultValueImpl() { return Boolean.TRUE; }
The default value will be applied to the attribute when a getValue() call detects that the attribute has no value.
(Remark: Each attribute may define it's 'no value' condition by implementing isEmptyValue().)
The getValue() method calls in this case the method setBackingValue(defaltValue) to apply the default. The attribute is not marked as changed when a default value was applied.