Record Class Attributes
java.lang.Object
java.lang.Record
org.microbean.attributes.Attributes
- Record Components:
name
- a non-null
name of thisAttributes
values
- a non-null
Map
of named values associated with thisAttributes
notes
- a non-null
Map
of non-normative named values associated with thisAttributes
attributes
- a non-null
Map
of named metadata associated with thisAttributes
- All Implemented Interfaces:
Comparable<Attributes>
,Constable
,Value<Attributes>
public record Attributes(String name, Map<String,Value<?>> values, Map<String,Value<?>> notes, Map<String,List<Attributes>> attributes)
extends Record
implements Value<Attributes>
- Author:
- Laird Nelson
-
Constructor Summary
ConstructorsConstructorDescriptionAttributes
(String name, Map<String, Value<?>> values, Map<String, Value<?>> notes, Map<String, List<Attributes>> attributes) Creates a newAttributes
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattributes
record component.final List
<Attributes> attributes
(String key) Returns aList
ofAttributes
associated with the suppliedkey
, or an emptyList
if there is no suchList
.final boolean
attributesSatisfy
(Predicate<? super Attributes> p) Returnstrue
if any of the attributes reachable from thisAttributes
satisfy the suppliedPredicate
.final int
compareTo
(Attributes other) final Optional
<DynamicConstantDesc<Attributes>> final boolean
final int
hashCode()
Returns a hash code value for thisAttributes
derived solely from its values.final boolean
isa
(Attributes a) name()
Returns the value of thename
record component.notes()
Returns the value of thenotes
record component.static final Attributes
Returns anAttributes
comprising the supplied arguments.static final Attributes
Returns anAttributes
comprising the supplied arguments.static final Attributes
of
(String name, List<Attributes> attributes) Returns anAttributes
comprising the supplied arguments.static final Attributes
of
(String name, Map<String, Value<?>> values, Map<String, Value<?>> notes, Map<String, List<Attributes>> attributes) Returns anAttributes
comprising the supplied arguments.static final Attributes
of
(String name, Attributes... attributes) Returns anAttributes
comprising the supplied arguments.final String
toString()
Returns a string representation of this record class.final <T extends Value<T>>
Tvalues()
Returns the value of thevalues
record component.
-
Constructor Details
-
Attributes
public Attributes(String name, Map<String, Value<?>> values, Map<String, Value<?>> notes, Map<String, List<Attributes>> attributes) Creates a newAttributes
.- Parameters:
name
- a non-null
name of thisAttributes
values
- a non-null
Map
of named values associated with thisAttributes
notes
- a non-null
Map
of non-normative named values associated with thisAttributes
attributes
- a non-null
Map
of named metadata associated with thisAttributes
- Throws:
NullPointerException
- if any argument isnull
-
-
Method Details
-
attributes
Returns aList
ofAttributes
associated with the suppliedkey
, or an emptyList
if there is no suchList
.- Parameters:
key
- aString
; must not benull
- Returns:
- a non-
null
List
ofAttributes
- Throws:
NullPointerException
- ifkey
isnull
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Attributes>
-
describeConstable
- Specified by:
describeConstable
in interfaceConstable
-
equals
Returnstrue
if thisAttributes
equals the suppliedObject
.If the supplied
Object
is also anAttributes
and has a name equal to thisAttributes
' name and a valuesMap
equal to thisAttributes
' valuesMap
, this method returnstrue
.This method returns
false
in all other cases.- Specified by:
equals
in classRecord
- Parameters:
other
- anObject
; may benull
- Returns:
true
if thisAttributes
equals the suppliedObject
- See Also:
-
hashCode
Returns a hash code value for thisAttributes
derived solely from its values. -
isa
Returnstrue
ifa
appears in theattributes
of thisAttributes
, or any of their attributes.Notably, this method does not return
true
if thisAttributes
is equal toa
.- Parameters:
a
- anAttributes
; must not benull
- Returns:
true
ifa
appears in theattributes
of thisAttributes
, or any of their attributes- Throws:
NullPointerException
- ifa
isnull
- See Also:
-
attributesSatisfy
Returnstrue
if any of the attributes reachable from thisAttributes
satisfy the suppliedPredicate
.- Parameters:
p
- aPredicate
; must not benull
- Returns:
true
if any of the attributes reachable from thisAttributes
satisfy the suppliedPredicate
;false
otherwise- Throws:
NullPointerException
- ifp
isnull
- See Also:
-
value
- Type Parameters:
T
- the type of theValue
- Parameters:
name
- the name; must not benull
- Returns:
- a suitably-typed
Value
indexed under the suppliedname
, ornull
if no suchValue
exists - Throws:
NullPointerException
- ifname
isnull
ClassCastException
- if<T>
does not match the actual type of theValue
indexed under the suppliedname
-
of
Returns anAttributes
comprising the supplied arguments.- Parameters:
name
- the name; must not benull
- Returns:
- a non-
null
Attributes
- Throws:
NullPointerException
- ifname
isnull
- See Also:
-
of
Returns anAttributes
comprising the supplied arguments.- Parameters:
name
- the name; must not benull
valueValue
- aString
that will be indexed under the key "value
"; must not benull
- Returns:
- a non-
null
Attributes
- Throws:
NullPointerException
- ifname
orvalueValue
isnull
- See Also:
-
of
Returns anAttributes
comprising the supplied arguments.- Parameters:
name
- the name; must not benull
attributes
- an array ofAttributes
; may benull
- Returns:
- a non-
null
Attributes
- Throws:
NullPointerException
- ifname
isnull
- See Also:
-
of
Returns anAttributes
comprising the supplied arguments.- Parameters:
name
- the name; must not benull
attributes
- a non-null
List
ofAttributes
- Returns:
- a non-
null
Attributes
- Throws:
NullPointerException
- if any argument isnull
- See Also:
-
of
public static final Attributes of(String name, Map<String, Value<?>> values, Map<String, Value<?>> notes, Map<String, List<Attributes>> attributes) Returns anAttributes
comprising the supplied arguments.- Parameters:
name
- the name; must not benull
values
- aMap
ofValue
s indexed byString
keys; must not benull
notes
- aMap
ofValue
s indexed byString
keys containing descriptive information only; must not benull
; not incorporated into equality calculationsattributes
- aMap
ofList
s ofAttributes
instances denoting metadata for a given value invalues
(or for thisAttributes
as a whole if the key in question is equal toname
); must not benull
- Returns:
- a non-
null
Attributes
- Throws:
NullPointerException
- if any argument isnull
-
toString
-
name
-
values
-
notes
-
attributes
Returns the value of theattributes
record component.- Returns:
- the value of the
attributes
record component
-