public final class NumberNode extends Node
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.
Node.NonNumericFloat
Constructor and Description |
---|
NumberNode(java.lang.Number value,
SourceLocation sourceLocation) |
Modifier and Type | Method and 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 a
NumberNode , throwing
ExpectationNotMetException when the node is the wrong type. |
NumberNode |
expectNumberNode(java.util.function.Supplier<java.lang.String> errorMessage)
Casts the current node to a
NumberNode , throwing
ExpectationNotMetException 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() |
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
public NumberNode(java.lang.Number value, SourceLocation sourceLocation)
public java.lang.Number getValue()
public boolean isNaturalNumber()
public boolean isFloatingPointNumber()
public <R> R accept(NodeVisitor<R> visitor)
Node
public NumberNode expectNumberNode(java.lang.String errorMessage)
Node
NumberNode
, throwing
ExpectationNotMetException
when the node is the wrong type.expectNumberNode
in class Node
errorMessage
- Error message to use if the node is of the wrong type.public NumberNode expectNumberNode(java.util.function.Supplier<java.lang.String> errorMessage)
Node
NumberNode
, throwing
ExpectationNotMetException
when the node is the wrong type.expectNumberNode
in class Node
errorMessage
- Error message supplier.public java.util.Optional<NumberNode> asNumberNode()
Node
asNumberNode
in class Node
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object