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.OverwriteModeNested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base -
Field Summary
FieldsFields inherited from class tools.jackson.databind.node.ValueNode
BD_MAX_INTEGER, BD_MAX_LONG, BD_MAX_SHORT, BD_MIN_INTEGER, BD_MIN_LONG, BD_MIN_SHORT, BI_MAX_INTEGER, BI_MAX_LONG, BI_MAX_SHORT, BI_MIN_INTEGER, BI_MIN_LONG, BI_MIN_SHORT, MISSINGFields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BooleanMethod sub-classes should override if they can producebooleanvalues viaBaseJsonNode.asBoolean()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).protected StringMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).protected StringMethod for implementation classes to return a short description of contained value, to be used in error messages.final booleanMethod that will try to convert value of this node to a Javaboolean.final booleanasBoolean(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().asToken()Method that can be used for efficient type detection when using stream abstraction for traversing nodes.booleanMethod that will try to access value of this node as a Javabooleanwhich works if (and only if) node contains JSON boolean value: if not, aJsonNodeExceptionwill be thrown.booleanbooleanValue(boolean defaultValue) Method similar toJsonNode.booleanValue(), but that will return specifieddefaultValueif 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.booleanEquality for node objects is defined as full (deep) value equality.static BooleanNodegetFalse()Return the type of this nodestatic BooleanNodegetTrue()inthashCode()protected Objectfinal voidserialize(JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.static BooleanNodevalueOf(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, serializeWithTypeMethods 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, asFloat, asFloat, asFloatOpt, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asShort, asShort, asShortOpt, asString, asString, asStringOpt, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, binaryValue, decimalValue, decimalValue, decimalValueOpt, doubleValue, doubleValue, doubleValueOpt, findPath, floatValue, floatValue, floatValueOpt, intValue, intValue, intValueOpt, isEmbeddedValue, isMissingNode, longValue, longValue, longValueOpt, numberType, numberValue, required, required, shortValue, shortValue, shortValueOpt, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, canConvertToInt, canConvertToLong, canConvertToShort, 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, withObjectPropertyMethods 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:JsonNodeReturn the type of this node- Specified by:
getNodeTypein classJsonNode- Returns:
- the node type as a
JsonNodeTypeenum value
-
asToken
Description copied from class:BaseJsonNodeMethod that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the firstJsonTokenthat equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple) -
_valueDesc
Description copied from class:BaseJsonNodeMethod for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDescin classBaseJsonNode
-
deepCopy
Description copied from class:ValueNodeAll current value nodes are immutable, so we can just return them as is. -
asBoolean
public final boolean asBoolean()Description copied from class:JsonNodeMethod 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;nullmaps to false and Strings 'true' and 'false' map to corresponding values. Other values (including structured types like Objects and Arrays) will result in aJsonNodeExceptionbeing thrown.- Overrides:
asBooleanin classBaseJsonNode- Returns:
- Boolean value this node represents, if coercible; exception otherwise
-
asBoolean
public final boolean asBoolean(boolean defaultValue) Description copied from class:JsonNodeSimilar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values, will return specified default value.- Overrides:
asBooleanin classBaseJsonNode
-
asBooleanOpt
Description copied from class:JsonNodeSimilar toJsonNode.asBoolean(), but instead of throwing an exception for non-coercible values, will returnOptional.empty().- Overrides:
asBooleanOptin classBaseJsonNode
-
_asBoolean
Description copied from class:BaseJsonNodeMethod sub-classes should override if they can producebooleanvalues viaBaseJsonNode.asBoolean()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).- Overrides:
_asBooleanin classBaseJsonNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
booleanValue
public boolean booleanValue()Description copied from class:JsonNodeMethod that will try to access value of this node as a Javabooleanwhich works if (and only if) node contains JSON boolean value: if not, aJsonNodeExceptionwill be thrown.NOTE: for more lenient conversions, use
JsonNode.asBoolean()- Overrides:
booleanValuein classBaseJsonNode- Returns:
booleanvalue this node represents (if JSON boolean)
-
booleanValue
public boolean booleanValue(boolean defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.booleanValue(), but that will return specifieddefaultValueif this node does not contain a JSON boolean.- Overrides:
booleanValuein classBaseJsonNode- Parameters:
defaultValue- Value to return if this node does not contain a JSON boolean.- Returns:
- Java
booleanvalue this node represents (if JSON boolean);defaultValueotherwise
-
booleanValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.booleanValue(), but that will returnOptional.empty()if this node does not contain a JSON boolean.- Overrides:
booleanValueOptin classBaseJsonNode- Returns:
Optional<Boolean>value (if node represents JSON boolean);Optional.empty()otherwise
-
_asString
Description copied from class:BaseJsonNodeMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).- Overrides:
_asStringin classBaseJsonNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
serialize
Description copied from class:BaseJsonNodeMethod called to serialize node instances using given generator.- Specified by:
serializein interfaceJacksonSerializable- Specified by:
serializein classBaseJsonNode- Throws:
JacksonException
-
hashCode
public int hashCode()- Specified by:
hashCodein classBaseJsonNode
-
equals
Description copied from class:JsonNodeEquality 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.
-