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:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface dev.getelements.elements.sdk.Attributes
Attributes.Attribute<T>
-
Field Summary
Fields inherited from interface dev.getelements.elements.sdk.Attributes
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleAttributes
(Map<String, Object> attributes) Creates an instance of aSimpleAttributes
record class. -
Method Summary
Modifier and TypeMethodDescriptionasMap()
Returns a view of thisAttributes
object as aMap<String,
.Object> Returns the value of theattributes
record component.boolean
Indicates whether some other object is "equal to" this one.getAttributeOptional
(String name) Gets the attribute associated with thisAttributes
object.int
hashCode()
Returns a hash code value for this object.Returns a copy of thisAttributes
as an immutable copy.static SimpleAttributes
Constructs a new simple attributes instance with the default backing.void
setAttribute
(String name, Object obj) Sets the attribute with the supplied name and valuefinal String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface dev.getelements.elements.sdk.Attributes
asProperties, asProperties, getAttribute, stream
-
Constructor Details
-
SimpleAttributes
Creates an instance of aSimpleAttributes
record class.- Parameters:
attributes
- the value for theattributes
record component
-
-
Method Details
-
getAttributeNames
Description copied from interface:Attributes
- Specified by:
getAttributeNames
in interfaceAttributes
- Returns:
- the
List<String>
of attribute names
-
getAttributeOptional
Description copied from interface:Attributes
Gets the attribute associated with thisAttributes
object.- Specified by:
getAttributeOptional
in interfaceAttributes
- Parameters:
name
- the name of the attribute to fetch- Returns:
- an
Optional<Object>
for the value
-
asMap
Description copied from interface:Attributes
Returns a view of thisAttributes
object as aMap<String,
.Object> - Specified by:
asMap
in interfaceAttributes
- Returns:
- this
Attributes
as aMap<String,
Object>
-
setAttribute
Description copied from interface:MutableAttributes
Sets the attribute with the supplied name and value- Specified by:
setAttribute
in interfaceMutableAttributes
- Parameters:
name
- the name to setobj
- the value to set
-
immutableCopy
Description copied from interface:Attributes
Returns a copy of thisAttributes
as an immutable copy. Alternatively, if this instance is already immutable, then this will return this instance.- Specified by:
immutableCopy
in interfaceAttributes
- 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. -
equals
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 withObjects::equals(Object,Object)
. -
newDefaultInstance
Constructs a new simple attributes instance with the default backing.- Returns:
- a new
SimpleAttributes
-
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. -
attributes
Returns the value of theattributes
record component.- Returns:
- the value of the
attributes
record component
-