T - type of the value expected for this attribute@PublicApi @Immutable public class AttributeSpec<T> extends Object
AttributeSpec is the "attribute specification", a composite identifier of an attribute. See
package documentation for the definition of an attribute.
Attribute specification contains the following parts:
String identifier. Attributes that have the same identifier are considered to be semantically
same or similar.Map, which should be serializable to JSON (contain only simple types, maps
and arrays). Two specifications with the same ID and parameters are considered to be
semantically same.ValueFormat, which defines the type and possible operations on the resulting value.Use AttributeSpecBuilder to build an instance of AttributeSpec in the code.
StructureAttributeService,
AttributeSpecBuilder| Constructor and Description |
|---|
AttributeSpec(String id,
ValueFormat<T> format)
Constructs an attribute spec with the given ID and format, without parameters.
|
AttributeSpec(String id,
ValueFormat<T> format,
Map<String,Object> params)
Constructs an attribute spec with the given ID, format and parameters.
|
| Modifier and Type | Method and Description |
|---|---|
<V> AttributeSpec<V> |
as(ValueFormat<V> format)
Returns an attribute spec with the same ID and parameters, but with the given
ValueFormat. |
AttributeLoader<T> |
cast(AttributeLoader<?> loader)
Verifies and converts
AttributeLoader to another type with a different value format. |
boolean |
equals(Object o) |
ValueFormat<T> |
getFormat()
Returns the attribute's format.
|
String |
getId()
Returns the attribute's ID.
|
SpecParams |
getParams()
Returns the same as
getParamsMap(), but wrapped into accessor object. |
Map<String,Object> |
getParamsMap()
Returns the attribute's parameters as a read-only map.
|
int |
hashCode() |
boolean |
is(String id)
Checks if this attribute specification is for the given attribute ID.
|
boolean |
is(String id,
ValueFormat<?> format)
Checks if this attribute specification is for the given ID and format.
|
boolean |
is(ValueFormat<?> format)
Checks if this attribute specification contains the given format.
|
AttributeSpec<T> |
noParams()
Returns a new attribute spec with all parameters removed.
|
AttributeSpec<T> |
replaceParams(Map<String,Object> newParams)
Returns a new attribute spec with parameters replaced with a new map.
|
String |
toString() |
AttributeSpec<T> |
withParam(String name,
Object value)
Returns a new attribute spec with added parameter.
|
public AttributeSpec(String id, ValueFormat<T> format)
id - attribute IDformat - value formatpublic AttributeSpec(@NotNull
String id,
@NotNull
ValueFormat<T> format,
@Nullable
Map<String,Object> params)
id - attribute IDformat - value formatparams - parameters map@NotNull public String getId()
@NotNull public ValueFormat<T> getFormat()
@NotNull public Map<String,Object> getParamsMap()
@NotNull public SpecParams getParams()
getParamsMap(), but wrapped into accessor object.public boolean is(String id)
id - attribute's IDpublic boolean is(ValueFormat<?> format)
format - value formatpublic boolean is(String id, ValueFormat<?> format)
id - attribute's IDformat - value formatpublic <V> AttributeSpec<V> as(ValueFormat<V> format)
ValueFormat.format - the format for a new AttributeSpecpublic AttributeSpec<T> withParam(String name, Object value)
name - parameter namevalue - parameter valuepublic AttributeSpec<T> replaceParams(Map<String,Object> newParams)
newParams - replacement parameterspublic AttributeSpec<T> noParams()
public AttributeLoader<T> cast(AttributeLoader<?> loader)
AttributeLoader to another type with a different value format.Copyright © 2019 ALM Works. All Rights Reserved.