Record Class InheritedAttributes

java.lang.Object
java.lang.Record
dev.getelements.elements.sdk.util.InheritedAttributes
Record Components:
base - the base attributes, may be null and will be replaced with Attributes.emptyAttributes()
current - the current attributes that are inherited from the base attributes
All Implemented Interfaces:
Attributes

public record InheritedAttributes(Attributes base, Attributes current) extends Record implements Attributes
A type of Attributes that inherits from a base set of attributes.
  • Constructor Details

    • InheritedAttributes

      public InheritedAttributes(Attributes base, Attributes current)
      Creates an instance of a InheritedAttributes record class.
      Parameters:
      base - the value for the base record component
      current - the value for the current record component
  • Method Details

    • withAttributes

      public static InheritedAttributes withAttributes(Attributes current)
      Creates an InheritedAttributes object that inherits from the given attributes.
      Parameters:
      current - the attributes to inherit from
      Returns:
      the new InheritedAttributes
    • 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
    • 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
    • newDerivativeFrom

      public InheritedAttributes newDerivativeFrom(Attributes attributes)
      Derives a new set of attributes from the current set of attributes.
      Parameters:
      attributes - the attributes
      Returns:
      the new InheritedAttributes
    • newDerivativeFrom

      public InheritedMutableAttributes newDerivativeFrom(MutableAttributes attributes)
      Derives a new set of attributes from the current set of attributes.
      Parameters:
      attributes - the attributes
      Returns:
      the new InheritedAttributes
    • 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
    • hashCode

      public final 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 final boolean equals(Object o)
      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:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • base

      public Attributes base()
      Returns the value of the base record component.
      Returns:
      the value of the base record component
    • current

      public Attributes current()
      Returns the value of the current record component.
      Returns:
      the value of the current record component