Skip to content

Commit

Permalink
Fix #2223
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 12, 2019
1 parent 0ca6c28 commit 8d846ae
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Project: jackson-databind
#2204: Add `JsonNode.isEmpty()` as convenience alias
#2217: Suboptimal memory allocation in `TextNode.getBinaryValue()`
(reported by Christoph B)
#2223: Add `missingNode()` method in `JsonNodeFactory`

2.9.8 (15-Dec-2018)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,26 @@ protected ContainerNode(JsonNodeFactory nc) {

/*
/**********************************************************
/* JsonNodeCreator implementation, just dispatch to
/* the real creator
/* JsonNodeCreator implementation, Enumerated/singleton types
/**********************************************************
*/

@Override
public final BooleanNode booleanNode(boolean v) { return _nodeFactory.booleanNode(v); }

public JsonNode missingNode() {
return _nodeFactory.missingNode();
}

@Override
public final NullNode nullNode() { return _nodeFactory.nullNode(); }

/*
/**********************************************************
/* JsonNodeCreator implementation, just dispatch to real creator
/**********************************************************
*/

/**
* Factory method that constructs and returns an empty {@link ArrayNode}
* Construction is done using registered {@link JsonNodeFactory}.
Expand All @@ -79,12 +94,6 @@ protected ContainerNode(JsonNodeFactory nc) {
@Override
public final ObjectNode objectNode() { return _nodeFactory.objectNode(); }

@Override
public final NullNode nullNode() { return _nodeFactory.nullNode(); }

@Override
public final BooleanNode booleanNode(boolean v) { return _nodeFactory.booleanNode(v); }

@Override
public final NumericNode numberNode(byte v) { return _nodeFactory.numberNode(v); }
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public interface JsonNodeCreator
public ValueNode booleanNode(boolean v);
public ValueNode nullNode();

// Not yet in 2.10, will be added in 3.0
// public JsonNode missingNode();

// Numeric types

public ValueNode numberNode(byte v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.util.RawValue;

/**
Expand Down Expand Up @@ -108,6 +109,10 @@ public BooleanNode booleanNode(boolean v) {
@Override
public NullNode nullNode() { return NullNode.getInstance(); }

public JsonNode missingNode() {
return MissingNode.getInstance();
}

/*
/**********************************************************
/* Factory methods for numeric values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ public void testSimpleCreation()
assertTrue(f.numberNode((BigDecimal) null).isNull());

assertTrue(f.numberNode((BigInteger) null).isNull());

assertTrue(f.missingNode().isMissingNode());
}
}

0 comments on commit 8d846ae

Please sign in to comment.