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:
  • 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

      Optional<Boolean> getBoolean(String key) throws AttributeException
      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

      Optional<byte[]> getData(String key) throws AttributeException
      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

      Optional<Instant> getInstant(String key) throws AttributeException
      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

      Optional<Double> getDouble(String key) throws AttributeException
      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

      Collection<String> getKeys(String prefix) throws AttributeException
      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

      Collection<String> getKeys(String prefix, AttributeType<?> type) throws AttributeException
      Gets all attribute keys with the specified prefix and type.
      Parameters:
      prefix - the prefix to filter by
      type - 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

      Optional<Long> getLong(String key) throws AttributeException
      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

      Optional<Object> getObject(String key) throws AttributeException
      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

      Optional<String> getString(String key) throws AttributeException
      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

      boolean containsKey(String key) throws AttributeException
      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

      Map<String,Object> 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