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

public final Class MissingNode

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

This singleton node class is generated to denote "missing nodes" along paths that do not exist. For example, if a path via element of an array is requested for an element outside range of elements in the array; or for a non-array value, result will be reference to this node.

In most respects this placeholder node will act as NullNode; for example, for purposes of value conversions, value is considered to be null and represented as value zero when used for numeric conversions.

Field Summary

Modifier and TypeField and Description
private static final MissingNode
private static final long

Constructor Summary

AccessConstructor and Description
protected
MissingNode()

Note

visibility raised to `protected` in 2.9.3 to allow custom subtypes (which may not be greatest idea ever to have but was requested)

Method Summary

Modifier and TypeMethod and Description
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 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 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 <T extends JsonNode> T
deepCopy()

Overrides com.fasterxml.jackson.databind.node.ValueNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.

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 MissingNode
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.

public boolean
isMissingNode()

Overrides com.fasterxml.jackson.databind.JsonNode.isMissingNode.

Implements com.fasterxml.jackson.core.TreeNode.isMissingNode.

Method that returns true for "virtual" nodes which represent missing entries constructed by path accessor methods when there is no actual node matching given criteria.

protected Object
public JsonNode
require()

Overrides com.fasterxml.jackson.databind.JsonNode.require.

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

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.

public void
serializeWithType(JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer)

Overrides com.fasterxml.jackson.databind.node.ValueNode.serializeWithType.

Implements com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.

public String
toPrettyString()

Overrides com.fasterxml.jackson.databind.node.BaseJsonNode.toPrettyString.

Alternative to toString that will serialize this node using Jackson default pretty-printer.

public String
toString()

Overrides com.fasterxml.jackson.databind.node.BaseJsonNode.toString.

Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String.

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

Field Detail

instanceback to summary
private static final MissingNode instance
serialVersionUIDback to summary
private static final long serialVersionUID

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

Constructor Detail

MissingNodeback to summary
protected MissingNode()

Note

visibility raised to `protected` in 2.9.3 to allow custom subtypes (which may not be greatest idea ever to have but was requested)

Method Detail

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
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
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
deepCopyback to summary
public <T extends JsonNode> T deepCopy()

Overrides com.fasterxml.jackson.databind.node.ValueNode.deepCopy.

Doc from com.fasterxml.jackson.databind.node.ValueNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.

Returns:T

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

Node that is either a copy of this node (and all non-leaf children); or, for immutable leaf nodes, node itself.

Annotations
@SuppressWarnings:unchecked
@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 MissingNode 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
isMissingNodeback to summary
public boolean isMissingNode()

Overrides com.fasterxml.jackson.databind.JsonNode.isMissingNode.

Implements com.fasterxml.jackson.core.TreeNode.isMissingNode.

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

Method that returns true for "virtual" nodes which represent missing entries constructed by path accessor methods when there is no actual node matching given criteria.

Note

one and only one of methods isValueNode, isContainerNode and isMissingNode ever returns true for any given node.

Returns:boolean

True if this node represents a "missing" node

Annotations
@Override
readResolveback to summary
protected Object readResolve()
requireback to summary
public JsonNode require()

Overrides com.fasterxml.jackson.databind.JsonNode.require.

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

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

Returns:JsonNode

this node to allow chaining

Annotations
@SuppressWarnings:unchecked
@Override
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
serializeWithTypeback to summary
public void serializeWithType(JsonGenerator g, SerializerProvider provider, TypeSerializer typeSer) throws IOException

Overrides com.fasterxml.jackson.databind.node.ValueNode.serializeWithType.

Implements com.fasterxml.jackson.databind.JsonSerializable.serializeWithType.

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

Type information is needed, even if JsonNode instances are "plain" JSON, since they may be mixed with other types.

Annotations
@Override
toPrettyStringback to summary
public String toPrettyString()

Overrides com.fasterxml.jackson.databind.node.BaseJsonNode.toPrettyString.

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

Alternative to toString that will serialize this node using Jackson default pretty-printer.

Annotations
@Override
toStringback to summary
public String toString()

Overrides com.fasterxml.jackson.databind.node.BaseJsonNode.toString.

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

Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String. If you want other kinds of JSON output (or output formatted using one of other Jackson-supported data formats) make sure to use ObjectMapper or ObjectWriter to serialize an instance, for example:

   String json = objectMapper.writeValueAsString(rootNode);

Note

method defined as abstract to ensure all implementation classes explicitly implement method, instead of relying on Object#toString() definition.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object

Annotations
@Override