Interface AttributeValue
-
public interface AttributeValueSelector attribute values are the data model of selectors.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static AttributeValueemptyValue()Creates an emptyAttributeValueobject.default java.util.Collection<? extends AttributeValue>getFlattenedValues()Gets all of the attribute values contained in the attribute value.default AttributeValuegetPath(java.util.List<java.lang.String> path)Gets a property using a path to the property.AttributeValuegetProperty(java.lang.String key)Gets a property from the attribute value.static AttributeValueid(ShapeId id)Creates an 'id'AttributeValuefrom a shape ID.default booleanisPresent()Checks if the attribute value is considered present.static AttributeValueliteral(java.lang.Object literal)Creates anAttributeValuethat contains a literal value.static AttributeValuenode(Node node)Creates a 'node'AttributeValuefor aNode.static java.util.List<java.lang.String>parseScopedAttribute(SimpleParser parser)Uses the given parser to parse a scoped attribute production.static AttributeValueprojection(java.util.Collection<AttributeValue> values)Creates a 'projection'AttributeValue.static AttributeValueservice(ServiceShape service)Creates a 'service'AttributeValuefrom a service shape.static AttributeValueshape(Shape shape, java.util.Map<java.lang.String,java.util.Set<Shape>> vars)Creates a 'shape'AttributeValuefor the given shape.default java.lang.StringtoMessageString()Returns a string representation of the value that can be used for creating formatted messages.java.lang.StringtoString()Returns the string version of an attribute value.
-
-
-
Method Detail
-
toString
java.lang.String toString()
Returns the string version of an attribute value.- Overrides:
toStringin classjava.lang.Object- Returns:
- Returns the string representation or an empty string.
-
toMessageString
default java.lang.String toMessageString()
Returns a string representation of the value that can be used for creating formatted messages.This implementation gets the value of
toString()by default.- Returns:
- Returns the message string.
-
getProperty
AttributeValue getProperty(java.lang.String key)
Gets a property from the attribute value.This method never returns null. It should instead return a null value object when the property does not exist.
- Parameters:
key- Property to get.- Returns:
- Returns the nested property.
-
getPath
default AttributeValue getPath(java.util.List<java.lang.String> path)
Gets a property using a path to the property.- Parameters:
path- The path to select from the value.- Returns:
- Returns the created attribute value.
-
isPresent
default boolean isPresent()
Checks if the attribute value is considered present.Attribute value are considered present if they are not null. If the attribute value is a projection, then it is considered present if it is not empty.
- Returns:
- Returns true if present.
-
getFlattenedValues
default java.util.Collection<? extends AttributeValue> getFlattenedValues()
Gets all of the attribute values contained in the attribute value.This will yield a single result for normal attributes, or a list of multiple values for projections.
- Returns:
- Returns the flattened attribute values contained in the attribute value.
-
shape
static AttributeValue shape(Shape shape, java.util.Map<java.lang.String,java.util.Set<Shape>> vars)
Creates a 'shape'AttributeValuefor the given shape.- Parameters:
shape- Shape to path into.vars- Variables accessible to the shape.- Returns:
- Returns the created selector value.
-
id
static AttributeValue id(ShapeId id)
Creates an 'id'AttributeValuefrom a shape ID.- Parameters:
id- Shape ID to create.- Returns:
- Returns the created selector value.
-
service
static AttributeValue service(ServiceShape service)
Creates a 'service'AttributeValuefrom a service shape.- Parameters:
service- Shape to create.- Returns:
- Returns the created selector value.
-
emptyValue
static AttributeValue emptyValue()
Creates an emptyAttributeValueobject.- Returns:
- Returns the created selector value.
-
literal
static AttributeValue literal(java.lang.Object literal)
Creates anAttributeValuethat contains a literal value.- Parameters:
literal- Literal value to wrap.- Returns:
- Returns the created selector value.
-
node
static AttributeValue node(Node node)
Creates a 'node'AttributeValuefor aNode.- Parameters:
node- Node to create the value from.- Returns:
- Returns the created attribute value.
-
projection
static AttributeValue projection(java.util.Collection<AttributeValue> values)
Creates a 'projection'AttributeValue.- Parameters:
values- Values stored in the projection.- Returns:
- Returns the created projection.
-
parseScopedAttribute
static java.util.List<java.lang.String> parseScopedAttribute(SimpleParser parser)
Uses the given parser to parse a scoped attribute production.- Parameters:
parser- Parser to consume.- Returns:
- Returns the list of validated scoped attribute path segments.
- Throws:
java.lang.RuntimeException- if the parser does not contain a valid scoped attribute production.- See Also:
for an example of how this is used.
-
-