java.lang.Object
tools.jackson.databind.JacksonSerializable.Base
tools.jackson.databind.JsonNode
tools.jackson.databind.node.BaseJsonNode
tools.jackson.databind.node.ValueNode
tools.jackson.databind.node.BooleanNode
- All Implemented Interfaces:
Serializable
,Iterable<JsonNode>
,TreeNode
,JacksonSerializable
This concrete value class is used to contain boolean (true / false)
values. Only two instances are ever created, to minimize memory
usage.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.JsonNode
JsonNode.OverwriteMode
Nested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base
-
Field Summary
FieldsFields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Boolean
Method sub-classes should override if they can produceboolean
values viaBaseJsonNode.asBoolean()
-- if not, returnnull
(in which case appropriate error will be thrown or default value returned).protected String
Method sub-classes should override if they can produceString
values viaBaseJsonNode.asString()
-- if not, returnnull
(in which case appropriate error will be thrown or default value returned).protected String
Method for implementation classes to return a short description of contained value, to be used in error messages.final boolean
Method that will try to convert value of this node to a Javaboolean
.final boolean
asBoolean
(boolean defaultValue) Similar toJsonNode.asBoolean()
, but instead of throwing an exception for non-coercible values, will return specified default value.Similar toJsonNode.asBoolean()
, but instead of throwing an exception for non-coercible values, will returnOptional.empty()
.long
asLong
(long defaultValue) Method similar toJsonNode.asLong()
, but that will return specifieddefaultValue
if this node cannot be coerced tolong
(instead of throwing an exception).asToken()
Method that can be used for efficient type detection when using stream abstraction for traversing nodes.boolean
Method that will try to access value of this node as a Javaboolean
which works if (and only if) node contains JSON boolean value: if not, aJsonNodeException
will be thrown.boolean
booleanValue
(boolean defaultValue) Method similar toJsonNode.booleanValue()
, but that will return specifieddefaultValue
if this node does not contain a JSON boolean.Method similar toJsonNode.booleanValue()
, but that will returnOptional.empty()
if this node does not contain a JSON boolean.deepCopy()
All current value nodes are immutable, so we can just return them as is.boolean
Equality for node objects is defined as full (deep) value equality.static BooleanNode
getFalse()
Return the type of this nodestatic BooleanNode
getTrue()
int
hashCode()
protected Object
final void
serialize
(JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.static BooleanNode
valueOf
(boolean b) Methods inherited from class tools.jackson.databind.node.ValueNode
_at, findParent, findParents, findValue, findValues, findValuesAsString, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithType
Methods inherited from class tools.jackson.databind.node.BaseJsonNode
_jsonPointerIfValid, _reportBigDecimalCoercionNaNFail, _reportBigIntegerCoercionFractionFail, _reportBigIntegerCoercionNaNFail, _reportCoercionFail, _reportDoubleCoercionRangeFail, _reportFloatCoercionRangeFail, _reportIntCoercionFractionFail, _reportIntCoercionNaNFail, _reportIntCoercionRangeFail, _reportLongCoercionFractionFail, _reportLongCoercionNaNFail, _reportLongCoercionRangeFail, _reportShortCoercionFractionFail, _reportShortCoercionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asBigInteger, asBigInteger, asBigIntegerOpt, asDecimal, asDecimal, asDecimalOpt, asDouble, asDouble, asDoubleOpt, asInt, asInt, asIntOpt, asLong, asLongOpt, asString, asString, asStringOpt, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, binaryValue, decimalValue, decimalValue, decimalValueOpt, doubleValue, doubleValue, doubleValueOpt, findPath, floatValue, intValue, intValue, intValueOpt, isEmbeddedValue, isMissingNode, longValue, longValue, longValueOpt, numberType, numberValue, required, required, shortValue, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObject
Methods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, canConvertToInt, canConvertToLong, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isNull, isNumber, isObject, isPojo, isShort, isString, isTextual, isValueNode, iterator, optional, optional, properties, propertyNames, propertyStream, require, requiredAt, requiredAt, requireNonNull, size, spliterator, textValue, values, valueStream, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectProperty
Methods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Field Details
-
TRUE
-
FALSE
-
-
Constructor Details
-
BooleanNode
protected BooleanNode(boolean v)
-
-
Method Details
-
readResolve
-
getTrue
-
getFalse
-
valueOf
-
getNodeType
Description copied from class:JsonNode
Return the type of this node- Specified by:
getNodeType
in classJsonNode
- Returns:
- the node type as a
JsonNodeType
enum value
-
asToken
Description copied from class:BaseJsonNode
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonToken
that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple) -
_valueDesc
Description copied from class:BaseJsonNode
Method for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDesc
in classBaseJsonNode
-
deepCopy
Description copied from class:ValueNode
All current value nodes are immutable, so we can just return them as is. -
asBoolean
public final boolean asBoolean()Description copied from class:JsonNode
Method that will try to convert value of this node to a Javaboolean
. JSON Booleans map naturally; Integer numbers other than 0 map to true, and 0 maps to false;null
maps to false and Strings 'true' and 'false' map to corresponding values. Other values (including structured types like Objects and Arrays) will result in aJsonNodeException
being thrown.- Overrides:
asBoolean
in classBaseJsonNode
- Returns:
- Boolean value this node represents, if coercible; exception otherwise
-
asBoolean
public final boolean asBoolean(boolean defaultValue) Description copied from class:JsonNode
Similar toJsonNode.asBoolean()
, but instead of throwing an exception for non-coercible values, will return specified default value.- Overrides:
asBoolean
in classBaseJsonNode
-
asBooleanOpt
Description copied from class:JsonNode
Similar toJsonNode.asBoolean()
, but instead of throwing an exception for non-coercible values, will returnOptional.empty()
.- Overrides:
asBooleanOpt
in classBaseJsonNode
-
_asBoolean
Description copied from class:BaseJsonNode
Method sub-classes should override if they can produceboolean
values viaBaseJsonNode.asBoolean()
-- if not, returnnull
(in which case appropriate error will be thrown or default value returned).- Overrides:
_asBoolean
in classBaseJsonNode
- Returns:
- Coerced value if possible; otherwise
null
to indicate this node cannot be coerced.
-
booleanValue
public boolean booleanValue()Description copied from class:JsonNode
Method that will try to access value of this node as a Javaboolean
which works if (and only if) node contains JSON boolean value: if not, aJsonNodeException
will be thrown.NOTE: for more lenient conversions, use
JsonNode.asBoolean()
- Overrides:
booleanValue
in classBaseJsonNode
- Returns:
boolean
value this node represents (if JSON boolean)
-
booleanValue
public boolean booleanValue(boolean defaultValue) Description copied from class:JsonNode
Method similar toJsonNode.booleanValue()
, but that will return specifieddefaultValue
if this node does not contain a JSON boolean.- Overrides:
booleanValue
in classBaseJsonNode
- Parameters:
defaultValue
- Value to return if this node does not contain a JSON boolean.- Returns:
- Java
boolean
value this node represents (if JSON boolean);defaultValue
otherwise
-
booleanValueOpt
Description copied from class:JsonNode
Method similar toJsonNode.booleanValue()
, but that will returnOptional.empty()
if this node does not contain a JSON boolean.- Overrides:
booleanValueOpt
in classBaseJsonNode
- Returns:
Optional<Boolean>
value (if node represents JSON boolean);Optional.empty()
otherwise
-
_asString
Description copied from class:BaseJsonNode
Method sub-classes should override if they can produceString
values viaBaseJsonNode.asString()
-- if not, returnnull
(in which case appropriate error will be thrown or default value returned).- Overrides:
_asString
in classBaseJsonNode
- Returns:
- Coerced value if possible; otherwise
null
to indicate this node cannot be coerced.
-
asLong
public long asLong(long defaultValue) Description copied from class:JsonNode
Method similar toJsonNode.asLong()
, but that will return specifieddefaultValue
if this node cannot be coerced tolong
(instead of throwing an exception).- Overrides:
asLong
in classBaseJsonNode
- Parameters:
defaultValue
- Value to return if this node cannot be coerced tolong
- Returns:
long
value this node represents, if possible to accurately represent;defaultValue
otherwise
-
serialize
Description copied from class:BaseJsonNode
Method called to serialize node instances using given generator.- Specified by:
serialize
in interfaceJacksonSerializable
- Specified by:
serialize
in classBaseJsonNode
- Throws:
JacksonException
-
hashCode
public int hashCode()- Specified by:
hashCode
in classBaseJsonNode
-
equals
Description copied from class:JsonNode
Equality for node objects is defined as full (deep) value equality. This means that it is possible to compare complete JSON trees for equality by comparing equality of root nodes.Note: marked as abstract to ensure all implementation classes define it properly and not rely on definition from
Object
.
-