Skip to content

Commit

Permalink
Fix #1799
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 1, 2017
1 parent e467b7e commit a43d23d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Project: jackson-databind
2.9.3 (not yet released)

#1604: Nested type arguments doesn't work with polymorphic types
#1799: Allow creation of custom sub-types of `NullNode`, `BooleanNode`, `MissingNode`
#1804: `ValueInstantiator.canInstantiate()` ignores `canCreateUsingArrayDelegate()`
(reported byb henryptung@github)

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/fasterxml/jackson/databind/JsonNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ public final boolean isContainerNode() {
}

@Override
public final boolean isMissingNode() {
return getNodeType() == JsonNodeType.MISSING;
public boolean isMissingNode() {
return false;
}

@Override
public final boolean isArray() {
return getNodeType() == JsonNodeType.ARRAY;
public boolean isArray() {
return false;
}

@Override
public final boolean isObject() {
return getNodeType() == JsonNodeType.OBJECT;
public boolean isObject() {
return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public JsonNodeType getNodeType() {
return JsonNodeType.ARRAY;
}

@Override
public boolean isArray() {
return true;
}

@Override public JsonToken asToken() { return JsonToken.START_ARRAY; }

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ public class BooleanNode
public final static BooleanNode FALSE = new BooleanNode(false);

private final boolean _value;

private BooleanNode(boolean v) { _value = v; }

/**
*<p>
* NOTE: visibility raised to `protected` in 2.9.3 to allow custom subtypes.
*/
protected BooleanNode(boolean v) { _value = v; }

public static BooleanNode getTrue() { return TRUE; }
public static BooleanNode getFalse() { return FALSE; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ public final class MissingNode
{
private final static MissingNode instance = new MissingNode();

private MissingNode() { }
/**
*<p>
* NOTE: visibility raised to `protected` in 2.9.3 to allow custom subtypes.
*/
protected MissingNode() { }

@Override
public boolean isMissingNode() {
return true;
}

// Immutable: no need to copy
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ public final class NullNode

public final static NullNode instance = new NullNode();

private NullNode() { }
/**
*<p>
* NOTE: visibility raised to `protected` in 2.9.3 to allow custom subtypes.
*/
protected NullNode() { }

public static NullNode getInstance() { return instance; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public JsonNodeType getNodeType() {
return JsonNodeType.OBJECT;
}

@Override
public final boolean isObject() {
return true;
}

@Override public JsonToken asToken() { return JsonToken.START_OBJECT; }

@Override
Expand Down

0 comments on commit a43d23d

Please sign in to comment.