Interface Attributes
- All Known Subinterfaces:
MutableAttributes
- All Known Implementing Classes:
AbstractAttributes,AbstractMutableAttributes,HashMutableAttributes
public interface Attributes
Base interface for accessing workflow attributes. Attributes represent the data associated with
workflow instances and can include various types of information such as user inputs, computed
values, and system metadata.
Attributes provides type-safe access to attribute values with support for multiple data types including primitives, objects, and binary data. All getter methods return Optional values to handle cases where attributes may not exist.
The interface supports filtering and querying attributes by type and prefix, making it easy to work with subsets of attributes or find specific types of data.
- Since:
- 1.0
- See Also:
-
MutableAttributesImmutableAttributesAttributeTypeAttributeEntryAttributeException
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Checks if an attribute with the specified key exists.static com.yworkflow.definition.model.attribute.ImmutableAttributesempty()Creates a new empty ImmutableAttributes instance.Gets an attribute value as an Object.getBoolean(String key) Gets a boolean attribute value.Optional<byte[]>Gets a binary data attribute value.Gets a double attribute value.Gets the complete attribute entry for a key.getInstant(String key) Gets an Instant attribute value.Gets an integer attribute value.getKeys()Gets all attribute keys.getKeys(AttributeType<?> type) Gets all attribute keys of the specified type.Gets all attribute keys with the specified prefix.getKeys(String prefix, AttributeType<?> type) Gets all attribute keys with the specified prefix and type.Gets a long attribute value.Gets an object attribute value.Gets a string attribute value.Gets the type of an attribute.toMap()Converts this Attributes instance to a Map representation.
-
Method Details
-
get
Gets an attribute value as an Object. This method returns the raw value without type checking.- Parameters:
key- the attribute key- Returns:
- an Optional containing the attribute value if found, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getBoolean
Gets a boolean attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the boolean value if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getData
Gets a binary data attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the byte array if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getInstant
Gets an Instant attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the Instant if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getDouble
Gets a double attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the double value if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getInt
Gets an integer attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the integer value if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getKeys
Gets all attribute keys.- Returns:
- a collection of all attribute keys
- Throws:
AttributeException- if there's an error accessing the attributes
-
getKeys
Gets all attribute keys of the specified type.- Parameters:
type- the attribute type to filter by- Returns:
- a collection of keys for attributes of the specified type
- Throws:
AttributeException- if there's an error accessing the attributes
-
getKeys
Gets all attribute keys with the specified prefix.- Parameters:
prefix- the prefix to filter by- Returns:
- a collection of keys that start with the specified prefix
- Throws:
AttributeException- if there's an error accessing the attributes
-
getKeys
Gets all attribute keys with the specified prefix and type.- Parameters:
prefix- the prefix to filter bytype- the attribute type to filter by- Returns:
- a collection of keys that start with the prefix and are of the specified type
- Throws:
AttributeException- if there's an error accessing the attributes
-
getLong
Gets a long attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the long value if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getObject
Gets an object attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the object value if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getString
Gets a string attribute value.- Parameters:
key- the attribute key- Returns:
- an Optional containing the string value if found and type matches, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getType
Gets the type of an attribute.- Parameters:
key- the attribute key- Returns:
- an Optional containing the attribute type if the key exists, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
getEntry
Gets the complete attribute entry for a key.- Parameters:
key- the attribute key- Returns:
- an Optional containing the attribute entry if found, empty otherwise
- Throws:
AttributeException- if there's an error accessing the attribute
-
containsKey
Checks if an attribute with the specified key exists.- Parameters:
key- the attribute key to check- Returns:
- true if the key exists, false otherwise
- Throws:
AttributeException- if there's an error checking the attribute
-
toMap
Converts this Attributes instance to a Map representation. Only attributes with non-null values are included in the resulting map.- Returns:
- a Map containing the attribute key-value pairs
-
empty
static com.yworkflow.definition.model.attribute.ImmutableAttributes empty()Creates a new empty ImmutableAttributes instance.- Returns:
- a new empty ImmutableAttributes instance
-