Class AbstractAttributes

java.lang.Object
com.yworkflow.definition.model.attribute.AbstractAttributes
All Implemented Interfaces:
Attributes
Direct Known Subclasses:
AbstractMutableAttributes

public abstract class AbstractAttributes extends Object implements Attributes
Abstract base class for attribute collections. AbstractAttributes provides a common implementation for the Attributes interface, handling type conversion and delegation to concrete implementations.
Since:
1.0
See Also:
  • Constructor Details

    • AbstractAttributes

      public AbstractAttributes()
  • Method Details

    • get

      public Optional<Object> get(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets an attribute value as an Object. This method returns the raw value without type checking.
      Specified by:
      get in interface Attributes
      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

      public Optional<Boolean> getBoolean(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets a boolean attribute value.
      Specified by:
      getBoolean in interface Attributes
      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

      public Optional<byte[]> getData(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets a binary data attribute value.
      Specified by:
      getData in interface Attributes
      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

      public Optional<Instant> getInstant(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets an Instant attribute value.
      Specified by:
      getInstant in interface Attributes
      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

      public Optional<Double> getDouble(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets a double attribute value.
      Specified by:
      getDouble in interface Attributes
      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

      public Optional<Integer> getInt(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets an integer attribute value.
      Specified by:
      getInt in interface Attributes
      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

      public Collection<String> getKeys() throws AttributeException
      Description copied from interface: Attributes
      Gets all attribute keys.
      Specified by:
      getKeys in interface Attributes
      Returns:
      a collection of all attribute keys
      Throws:
      AttributeException - if there's an error accessing the attributes
    • getKeys

      public Collection<String> getKeys(AttributeType<?> type) throws AttributeException
      Description copied from interface: Attributes
      Gets all attribute keys of the specified type.
      Specified by:
      getKeys in interface Attributes
      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

      public Collection<String> getKeys(String prefix) throws AttributeException
      Description copied from interface: Attributes
      Gets all attribute keys with the specified prefix.
      Specified by:
      getKeys in interface Attributes
      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
    • getLong

      public Optional<Long> getLong(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets a long attribute value.
      Specified by:
      getLong in interface Attributes
      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

      public Optional<Object> getObject(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets an object attribute value.
      Specified by:
      getObject in interface Attributes
      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

      public Optional<String> getString(String key) throws AttributeException
      Description copied from interface: Attributes
      Gets a string attribute value.
      Specified by:
      getString in interface Attributes
      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
    • get

      protected abstract <T> Optional<T> get(AttributeType<T> type, String key) throws AttributeException
      Abstract method to get an attribute value with the specified type and key. This method must be implemented by concrete subclasses to provide the actual storage mechanism for attributes.
      Type Parameters:
      T - the type of the attribute value
      Parameters:
      type - the attribute type
      key - the attribute key
      Returns:
      an Optional containing the attribute value if found
      Throws:
      AttributeException - if there is an error retrieving the attribute