Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.node

public Class NullNode

extends ValueNode
Class Inheritance
Imports
java.io.IOException, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.JsonNode, .SerializerProvider

This singleton value class is used to contain explicit JSON null value.

Field Summary

Modifier and TypeField and Description
public static final NullNode
private static final long

Constructor Summary

AccessConstructor and Description
protected
NullNode()

Note

visibility raised to `protected` in 2.9.3 to allow custom subtypes.

Method Summary

Modifier and TypeMethod and Description
public String
asText(String
The default value to return if this node's text value is absent.
defaultValue
)

Overrides com.fasterxml.jackson.databind.JsonNode.asText.

Returns the text value of this node or the provided defaultValue if this node does not have a text value.

public String
asText()

Implements abstract com.fasterxml.jackson.databind.JsonNode.asText.

Method that will return a valid String representation of the container value, if the node is a value node (method isValueNode returns true), otherwise empty String.

public JsonToken
asToken()

Implements abstract com.fasterxml.jackson.databind.node.ValueNode.asToken.

Implements com.fasterxml.jackson.core.TreeNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes.

public boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.equals.

Equality for node objects is defined as full (deep) value equality.

public static NullNode
public JsonNodeType
getNodeType()

Implements abstract com.fasterxml.jackson.databind.JsonNode.getNodeType.

Return the type of this node

public int
hashCode()

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.hashCode.

Returns a hash code value for this object.

protected Object
public JsonNode
requireNonNull()

Overrides com.fasterxml.jackson.databind.JsonNode.requireNonNull.

Method that may be called to verify that this node is neither so-called "missing node" (that is, one for which isMissingNode() returns true) nor "null node" (one for which isNull() returns true).

public final void
serialize(JsonGenerator g, SerializerProvider provider)

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serialize.

Implements com.fasterxml.jackson.databind.JsonSerializable.serialize.

Method called to serialize node instances using given generator.

Inherited from com.fasterxml.jackson.databind.node.ValueNode:
_atdeepCopyfindParentfindParentsfindValuefindValuesfindValuesAsTextgetgethashashasNonNullhasNonNullisEmptypathpathserializeWithType

Field Detail

instanceback to summary
public static final NullNode instance
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.node.ValueNode.serialVersionUID.

Constructor Detail

NullNodeback to summary
protected NullNode()

Note

visibility raised to `protected` in 2.9.3 to allow custom subtypes.

Method Detail

asTextback to summary
public String asText(String defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asText.

Doc from com.fasterxml.jackson.databind.JsonNode.asText.

Returns the text value of this node or the provided defaultValue if this node does not have a text value. Useful for nodes that are MissingNode or com.fasterxml.jackson.databind.node.NullNode, ensuring a default value is returned instead of null or missing indicators.

Note

This was deprecated in 2.17.0, but as discussed through [databind#4471], was un-deprecated in 2.17.1.

Parameters
defaultValue:String

The default value to return if this node's text value is absent.

Returns:String

The text value of this node, or defaultValue if the text value is absent.

Annotations
@Override
asTextback to summary
public String asText()

Implements abstract com.fasterxml.jackson.databind.JsonNode.asText.

Doc from com.fasterxml.jackson.databind.JsonNode.asText.

Method that will return a valid String representation of the container value, if the node is a value node (method isValueNode returns true), otherwise empty String.

Annotations
@Override
asTokenback to summary
public JsonToken asToken()

Implements abstract com.fasterxml.jackson.databind.node.ValueNode.asToken.

Implements com.fasterxml.jackson.core.TreeNode.asToken.

Doc from com.fasterxml.jackson.databind.node.BaseJsonNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)

Returns:JsonToken

Doc from com.fasterxml.jackson.core.TreeNode.asToken.

JsonToken that is most closely associated with the node type

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Implements abstract com.fasterxml.jackson.databind.JsonNode.equals.

Doc from com.fasterxml.jackson.databind.JsonNode.equals.

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 java.lang.Object.

Parameters
o:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getInstanceback to summary
public static NullNode getInstance()
getNodeTypeback to summary
public JsonNodeType getNodeType()

Implements abstract com.fasterxml.jackson.databind.JsonNode.getNodeType.

Doc from com.fasterxml.jackson.databind.JsonNode.getNodeType.

Return the type of this node

Returns:JsonNodeType

the node type as a JsonNodeType enum value

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
readResolveback to summary
protected Object readResolve()
requireNonNullback to summary
public JsonNode requireNonNull()

Overrides com.fasterxml.jackson.databind.JsonNode.requireNonNull.

Doc from com.fasterxml.jackson.databind.JsonNode.requireNonNull.

Method that may be called to verify that this node is neither so-called "missing node" (that is, one for which isMissingNode() returns true) nor "null node" (one for which isNull() returns true). If non-null non-missing node, this is returned to allow chaining; otherwise IllegalArgumentException is thrown.

Returns:JsonNode

this node to allow chaining

Annotations
@SuppressWarnings:unchecked
@Override
serializeback to summary
public final void serialize(JsonGenerator g, SerializerProvider provider) throws IOException

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serialize.

Implements com.fasterxml.jackson.databind.JsonSerializable.serialize.

Doc from com.fasterxml.jackson.databind.node.BaseJsonNode.serialize.

Method called to serialize node instances using given generator.

Annotations
@Override