Record Class SimpleAttributes

java.lang.Object
java.lang.Record
dev.getelements.elements.sdk.util.SimpleAttributes
All Implemented Interfaces:
Attributes, MutableAttributes, Serializable

public record SimpleAttributes(Map<String,Object> attributes) extends Record implements MutableAttributes, Serializable
Simple implementation of Attributes backed by a Map<String,Object>.
See Also:
  • Constructor Details

    • SimpleAttributes

      public SimpleAttributes(Map<String,Object> attributes)
      Creates an instance of a SimpleAttributes record class.
      Parameters:
      attributes - the value for the attributes record component
  • Method Details

    • getAttributeNames

      public Set<String> getAttributeNames()
      Description copied from interface: Attributes
      Gets a List<String> containing all attribute names contained in this instance.
      Specified by:
      getAttributeNames in interface Attributes
      Returns:
      the List<String> of attribute names
    • getAttributeOptional

      public Optional<Object> getAttributeOptional(String name)
      Description copied from interface: Attributes
      Gets the attribute associated with this Attributes object.
      Specified by:
      getAttributeOptional in interface Attributes
      Parameters:
      name - the name of the attribute to fetch
      Returns:
      an Optional<Object> for the value
    • asMap

      public Map<String,Object> asMap()
      Description copied from interface: Attributes
      Returns a view of this Attributes object as a Map<String,Object>.
      Specified by:
      asMap in interface Attributes
      Returns:
      this Attributes as a Map<String,Object>
    • setAttribute

      public void setAttribute(String name, Object obj)
      Description copied from interface: MutableAttributes
      Sets the attribute with the supplied name and value
      Specified by:
      setAttribute in interface MutableAttributes
      Parameters:
      name - the name to set
      obj - the value to set
    • immutableCopy

      public Attributes immutableCopy()
      Description copied from interface: Attributes
      Returns a copy of this Attributes as an immutable copy. Alternatively, if this instance is already immutable, then this will return this instance.
      Specified by:
      immutableCopy in interface Attributes
      Returns:
      an immutable copy of this Attributes
    • hashCode

      public int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public boolean equals(Object that)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      that - the object with which to compare
      Returns:
      true if this object is the same as the that argument; false otherwise.
    • newDefaultInstance

      public static SimpleAttributes newDefaultInstance()
      Constructs a new simple attributes instance with the default backing.
      Returns:
      a new SimpleAttributes
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • attributes

      public Map<String,Object> attributes()
      Returns the value of the attributes record component.
      Returns:
      the value of the attributes record component