Package com.yworkflow.definition.model
Interface MutableAttributes
- All Superinterfaces:
Attributes
- All Known Implementing Classes:
AbstractMutableAttributes,HashMutableAttributes
Provides mutable access to workflow attributes. MutableAttributes extends the base Attributes
interface to add methods for setting, updating, and removing attribute values. This interface is
used for building and modifying workflow data during execution.
MutableAttributes provides both imperative (set) and functional (with) methods for each attribute type. The imperative methods modify the current instance, while the functional methods return a new instance with the modification applied, supporting fluent programming patterns.
All setter methods throw AttributeException if there are validation errors or type conflicts. The interface supports various data types including primitives, objects, and binary data.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic MutableAttributesCreates a new empty MutableAttributes instance.voidremove()Removes all attributes from this instance.voidRemoves the attribute with the specified key.voidsetAttributes(MutableAttributes other) Sets all attributes from another MutableAttributes instance.voidsetBoolean(String key, boolean value) Sets a boolean attribute value.voidSets a binary data attribute value.voidSets a double attribute value.voidsetInstant(String key, Instant value) Sets an Instant attribute value.voidSets an integer attribute value.voidSets a long attribute value.voidSets an object attribute value.voidSets a string attribute value.Converts this MutableAttributes instance to an ImmutableAttributes instance.withAttributes(MutableAttributes other) Creates a new MutableAttributes instance with all attributes from another instance.withBoolean(String key, boolean value) Creates a new MutableAttributes instance with the specified boolean value.Creates a new MutableAttributes instance with the specified binary data value.withDouble(String key, double value) Creates a new MutableAttributes instance with the specified double value.withInstant(String key, Instant value) Creates a new MutableAttributes instance with the specified Instant value.Creates a new MutableAttributes instance with the specified integer value.Creates a new MutableAttributes instance with the specified long value.withObject(String key, Object value) Creates a new MutableAttributes instance with the specified object value.withString(String key, String value) Creates a new MutableAttributes instance with the specified string value.Methods inherited from interface com.yworkflow.definition.model.attribute.Attributes
containsKey, get, getBoolean, getData, getDouble, getEntry, getInstant, getInt, getKeys, getKeys, getKeys, getKeys, getLong, getObject, getString, getType, toMap
-
Method Details
-
setBoolean
Sets a boolean attribute value.- Parameters:
key- the attribute keyvalue- the boolean value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withBoolean
Creates a new MutableAttributes instance with the specified boolean value.- Parameters:
key- the attribute keyvalue- the boolean value to set- Returns:
- a new MutableAttributes instance with the boolean value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setData
Sets a binary data attribute value.- Parameters:
key- the attribute keyvalue- the byte array value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withData
Creates a new MutableAttributes instance with the specified binary data value.- Parameters:
key- the attribute keyvalue- the byte array value to set- Returns:
- a new MutableAttributes instance with the binary data value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setInstant
Sets an Instant attribute value.- Parameters:
key- the attribute keyvalue- the Instant value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withInstant
Creates a new MutableAttributes instance with the specified Instant value.- Parameters:
key- the attribute keyvalue- the Instant value to set- Returns:
- a new MutableAttributes instance with the Instant value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setDouble
Sets a double attribute value.- Parameters:
key- the attribute keyvalue- the double value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withDouble
Creates a new MutableAttributes instance with the specified double value.- Parameters:
key- the attribute keyvalue- the double value to set- Returns:
- a new MutableAttributes instance with the double value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setInt
Sets an integer attribute value.- Parameters:
key- the attribute keyvalue- the integer value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withInt
Creates a new MutableAttributes instance with the specified integer value.- Parameters:
key- the attribute keyvalue- the integer value to set- Returns:
- a new MutableAttributes instance with the integer value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setLong
Sets a long attribute value.- Parameters:
key- the attribute keyvalue- the long value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withLong
Creates a new MutableAttributes instance with the specified long value.- Parameters:
key- the attribute keyvalue- the long value to set- Returns:
- a new MutableAttributes instance with the long value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setObject
Sets an object attribute value.- Parameters:
key- the attribute keyvalue- the object value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withObject
Creates a new MutableAttributes instance with the specified object value.- Parameters:
key- the attribute keyvalue- the object value to set- Returns:
- a new MutableAttributes instance with the object value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setString
Sets a string attribute value.- Parameters:
key- the attribute keyvalue- the string value to set- Throws:
AttributeException- if there's a validation error or type conflict
-
withString
Creates a new MutableAttributes instance with the specified string value.- Parameters:
key- the attribute keyvalue- the string value to set- Returns:
- a new MutableAttributes instance with the string value
- Throws:
AttributeException- if there's a validation error or type conflict
-
setAttributes
Sets all attributes from another MutableAttributes instance.- Parameters:
other- the other MutableAttributes instance to copy from- Throws:
AttributeException- if there's a validation error or type conflict
-
withAttributes
Creates a new MutableAttributes instance with all attributes from another instance.- Parameters:
other- the other MutableAttributes instance to copy from- Returns:
- a new MutableAttributes instance with all attributes from the other instance
- Throws:
AttributeException- if there's a validation error or type conflict
-
remove
Removes the attribute with the specified key.- Parameters:
key- the key of the attribute to remove- Throws:
AttributeException- if there's an error removing the attribute
-
remove
Removes all attributes from this instance.- Throws:
AttributeException- if there's an error removing the attributes
-
mutableAttributes
Creates a new empty MutableAttributes instance.- Returns:
- a new empty MutableAttributes instance
-
toImmutable
Converts this MutableAttributes instance to an ImmutableAttributes instance. This is useful for passing attributes to workflow operations that require immutable data.- Returns:
- an ImmutableAttributes instance containing all attributes from this instance
- Throws:
AttributeException- if there's an error during conversion
-