Class NumberNode
- java.lang.Object
-
- software.amazon.smithy.model.node.Node
-
- software.amazon.smithy.model.node.NumberNode
-
- All Implemented Interfaces:
FromSourceLocation
,ToNode
public final class NumberNode extends Node
Represents a number node. Number nodes contain aNumber
value.Number nodes contain a value. You can inspect its type by calling
isNaturalNumber()
orisFloatingPointNumber()
. Natural numbers are positive, or negative numbers without a decimal part.
-
-
Constructor Summary
Constructors Constructor Description NumberNode(java.lang.Number value, SourceLocation sourceLocation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> R
accept(NodeVisitor<R> visitor)
Accepts a visitor with the node.java.util.Optional<NumberNode>
asNumberNode()
Gets the node as an NumberNode if it is an number.boolean
equals(java.lang.Object other)
NumberNode
expectNumberNode(java.lang.String errorMessage)
Casts the current node to aNumberNode
, throwingExpectationNotMetException
when the node is the wrong type.NodeType
getType()
Gets the type of the node.java.lang.Number
getValue()
Gets the number value.int
hashCode()
boolean
isFloatingPointNumber()
Returns true if the node contains a floating point number.boolean
isNaturalNumber()
Returns true if the node contains a natural number.java.lang.String
toString()
-
Methods inherited from class software.amazon.smithy.model.node.Node
arrayNode, arrayNode, asArrayNode, asBooleanNode, asNullNode, asObjectNode, assertEquals, asStringNode, diff, expectArrayNode, expectArrayNode, expectBooleanNode, expectBooleanNode, expectNullNode, expectNullNode, expectNumberNode, expectObjectNode, expectObjectNode, 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 Detail
-
NumberNode
public NumberNode(java.lang.Number value, SourceLocation sourceLocation)
-
-
Method Detail
-
getValue
public java.lang.Number 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.
-
accept
public <R> R accept(NodeVisitor<R> visitor)
Description copied from class:Node
Accepts a visitor with the node.
-
expectNumberNode
public NumberNode expectNumberNode(java.lang.String errorMessage)
Description copied from class:Node
Casts the current node to aNumberNode
, throwingExpectationNotMetException
when the node is the wrong type.- Overrides:
expectNumberNode
in classNode
- Parameters:
errorMessage
- Error message to use if the node is of the wrong type.- Returns:
- Returns a number node.
-
asNumberNode
public java.util.Optional<NumberNode> asNumberNode()
Description copied from class:Node
Gets the node as an NumberNode if it is an number.- Overrides:
asNumberNode
in classNode
- Returns:
- Returns the optional NumberNode.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-