Class NumberNode
java.lang.Object
software.amazon.smithy.model.node.Node
software.amazon.smithy.model.node.NumberNode
- All Implemented Interfaces:
FromSourceLocation,ToNode
Represents a number node. Number nodes contain a
Number value.
Number nodes contain a value. You can inspect its type by calling
isNaturalNumber() or isFloatingPointNumber(). Natural
numbers are positive, or negative numbers without a decimal part.
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.smithy.model.node.Node
Node.NonNumericFloat -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<R> Raccept(NodeVisitor<R> visitor) Accepts a visitor with the node.Gets the node as an NumberNode if it is an number.booleanexpectNumberNode(String errorMessage) Casts the current node to aNumberNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.expectNumberNode(Supplier<String> errorMessage) Casts the current node to aNumberNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.getType()Gets the type of the node.getValue()Gets the number value.inthashCode()booleanReturns true if the node contains a floating point number.booleanReturns true if the node contains a natural number.toString()Methods inherited from class software.amazon.smithy.model.node.Node
arrayNode, arrayNode, asArrayNode, asBooleanNode, asNullNode, asObjectNode, assertEquals, asStringNode, diff, expectArrayNode, expectArrayNode, expectArrayNode, expectBooleanNode, expectBooleanNode, expectBooleanNode, expectNullNode, expectNullNode, expectNullNode, expectNumberNode, expectObjectNode, expectObjectNode, expectObjectNode, expectStringNode, expectStringNode, expectStringNode, 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 Details
-
NumberNode
-
-
Method Details
-
getValue
Gets the number value.- Returns:
- Returns a number.
-
isNaturalNumber
public boolean isNaturalNumber()Returns true if the node contains a natural number.- Returns:
- Returns true if the node contains a natural number.
-
isFloatingPointNumber
public boolean isFloatingPointNumber()Returns true if the node contains a floating point number.- Returns:
- Returns true if the node contains a floating point number.
-
getType
Description copied from class:NodeGets the type of the node. -
accept
Description copied from class:NodeAccepts a visitor with the node. -
expectNumberNode
Description copied from class:NodeCasts the current node to aNumberNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.- Overrides:
expectNumberNodein classNode- Parameters:
errorMessage- Error message to use if the node is of the wrong type.- Returns:
- Returns a number node.
-
expectNumberNode
Description copied from class:NodeCasts the current node to aNumberNode, throwingExpectationNotMetExceptionwhen the node is the wrong type.- Overrides:
expectNumberNodein classNode- Parameters:
errorMessage- Error message supplier.- Returns:
- Returns a number node.
-
asNumberNode
Description copied from class:NodeGets the node as an NumberNode if it is an number.- Overrides:
asNumberNodein classNode- Returns:
- Returns the optional NumberNode.
-
equals
-
hashCode
public int hashCode() -
toString
-