Class StringNode
- java.lang.Object
- 
- software.amazon.smithy.model.node.Node
- 
- software.amazon.smithy.model.node.StringNode
 
 
- 
- All Implemented Interfaces:
- java.lang.Comparable<StringNode>,- FromSourceLocation,- ToNode
 
 public final class StringNode extends Node implements java.lang.Comparable<StringNode> Represents a string node.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class software.amazon.smithy.model.node.NodeNode.NonNumericFloat
 
- 
 - 
Constructor SummaryConstructors Constructor Description StringNode(java.lang.String value, SourceLocation sourceLocation)Creates a new StringNode.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> Raccept(NodeVisitor<R> visitor)Accepts a visitor with the node.java.util.Optional<ShapeId>asShapeId()Gets the value of the string as a ShapeId if it is a valid Shape ID.java.util.Optional<StringNode>asStringNode()Gets the node as an StringNode if it is an string.intcompareTo(StringNode o)static Pair<StringNode,java.util.function.Consumer<java.lang.String>>createLazyString(java.lang.String placeholder, SourceLocation sourceLocation)Creates a StringNode that is lazily populated with a value provided by the givenSupplier.booleanequals(java.lang.Object other)java.lang.StringexpectOneOf(java.lang.String... validValues)Gets the string if it is one of the provided valid strings.java.lang.StringexpectOneOf(java.util.Collection<java.lang.String> validValues)Gets the string if it is one of the provided valid strings.ShapeIdexpectShapeId()Expects that the value of the string is a fully-qualified Shape ID.ShapeIdexpectShapeId(java.lang.String namespace)Expects that the value of the string is a Shape ID.StringNodeexpectStringNode(java.lang.String errorMessage)Casts the current node to aStringNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.StringNodeexpectStringNode(java.util.function.Supplier<java.lang.String> errorMessage)Casts the current node to aStringNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.NodeTypegetType()Gets the type of the node.java.lang.StringgetValue()Gets the string value.inthashCode()java.lang.StringtoString()- 
Methods inherited from class software.amazon.smithy.model.node.NodearrayNode, arrayNode, asArrayNode, asBooleanNode, asNullNode, asNumberNode, asObjectNode, assertEquals, diff, expectArrayNode, expectArrayNode, expectArrayNode, expectBooleanNode, expectBooleanNode, expectBooleanNode, expectNullNode, expectNullNode, expectNullNode, expectNumberNode, expectNumberNode, expectNumberNode, expectObjectNode, expectObjectNode, expectObjectNode, expectStringNode, from, from, from, from, fromNodes, fromNodes, fromStrings, fromStrings, getSourceLocation, isArrayNode, isBooleanNode, isNullNode, isNumberNode, isObjectNode, isStringNode, loadArrayOfString, nullNode, objectNode, objectNode, objectNodeBuilder, parse, parse, parse, parse, parseJsonWithComments, parseJsonWithComments, prettyPrintJson, prettyPrintJson, printJson, toNode, withDeepSortedKeys, withDeepSortedKeys
 
- 
 
- 
- 
- 
Constructor Detail- 
StringNodepublic StringNode(java.lang.String value, SourceLocation sourceLocation)Creates a new StringNode.- Parameters:
- value- Immutable value to set.
- sourceLocation- Source location of where the node was defined.
 
 
- 
 - 
Method Detail- 
createLazyStringpublic static Pair<StringNode,java.util.function.Consumer<java.lang.String>> createLazyString(java.lang.String placeholder, SourceLocation sourceLocation) Creates a StringNode that is lazily populated with a value provided by the givenSupplier.This method is used in the SmithyModelLoaderclass to be able to resolve unquoted strings to the appropriate shape ID. Because this can only be done after an entire model is loaded, setting the resolved value inside of a node needs to be deferred.Lazy string nodes are not thread safe and there's no validation to ensure that the supplier is invoked only once. Their usage should be rare and you should generally try to use an alternative approach. - Parameters:
- placeholder- Placeholder string to use until the supplier is called.
- sourceLocation- Location of where the value was originally defined.
- Returns:
- Returns a pair of the string node and the supplier to invoke with the value.
 
 - 
acceptpublic <R> R accept(NodeVisitor<R> visitor) Description copied from class:NodeAccepts a visitor with the node.
 - 
expectStringNodepublic StringNode expectStringNode(java.lang.String errorMessage) Description copied from class:NodeCasts the current node to aStringNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.- Overrides:
- expectStringNodein class- Node
- Parameters:
- errorMessage- Error message to use if the node is of the wrong type.
- Returns:
- Returns a string node.
 
 - 
expectStringNodepublic StringNode expectStringNode(java.util.function.Supplier<java.lang.String> errorMessage) Description copied from class:NodeCasts the current node to aStringNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.- Overrides:
- expectStringNodein class- Node
- Parameters:
- errorMessage- Error message supplier.
- Returns:
- Returns a string node.
 
 - 
asStringNodepublic java.util.Optional<StringNode> asStringNode() Description copied from class:NodeGets the node as an StringNode if it is an string.- Overrides:
- asStringNodein class- Node
- Returns:
- Returns the optional StringNode.
 
 - 
getValuepublic java.lang.String getValue() Gets the string value.- Returns:
- Returns the string value.
 
 - 
expectOneOfpublic java.lang.String expectOneOf(java.lang.String... validValues) Gets the string if it is one of the provided valid strings.- Parameters:
- validValues- A list of valid string values.
- Returns:
- The string value.
- Throws:
- ExpectationNotMetException- when the value is not one of the valid strings.
 
 - 
expectOneOfpublic java.lang.String expectOneOf(java.util.Collection<java.lang.String> validValues) Gets the string if it is one of the provided valid strings.- Parameters:
- validValues- A list of valid string values.
- Returns:
- The string value.
- Throws:
- ExpectationNotMetException- if the value is not in the list.
 
 - 
expectShapeIdpublic ShapeId expectShapeId(java.lang.String namespace) Expects that the value of the string is a Shape ID.- Parameters:
- namespace- Namespace to use when resolving relative shape IDs.
- Returns:
- Returns the parsed Shape ID.
 
 - 
expectShapeIdpublic ShapeId expectShapeId() Expects that the value of the string is a fully-qualified Shape ID.- Returns:
- Returns the parsed Shape ID.
 
 - 
asShapeIdpublic java.util.Optional<ShapeId> asShapeId() Gets the value of the string as a ShapeId if it is a valid Shape ID.- Returns:
- Returns the optional Shape ID.
 
 - 
equalspublic boolean equals(java.lang.Object other) - Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Overrides:
- hashCodein class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
compareTopublic int compareTo(StringNode o) - Specified by:
- compareToin interface- java.lang.Comparable<StringNode>
 
 
- 
 
-