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, withDeepSortedKeyspublic 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)
Nodepublic NumberNode expectNumberNode(java.lang.String errorMessage)
NodeNumberNode, throwing
ExpectationNotMetException when the node is the wrong type.expectNumberNode in class NodeerrorMessage - Error message to use if the node is of the wrong type.public NumberNode expectNumberNode(java.util.function.Supplier<java.lang.String> errorMessage)
NodeNumberNode, throwing
ExpectationNotMetException when the node is the wrong type.expectNumberNode in class NodeerrorMessage - Error message supplier.public java.util.Optional<NumberNode> asNumberNode()
NodeasNumberNode in class Nodepublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object