@Test public void testToJson() throws IOException { Value instance = new Value(10L); JsonNode expResult = new LongNode(10); JsonNode result = instance.toJson(); assertEquals(expResult, result); instance = new Value(Long.MAX_VALUE); expResult = new LongNode(Long.MAX_VALUE); result = instance.toJson(); assertEquals(expResult, result); instance = new Value(10.0D); expResult = new DoubleNode(10.0D); result = instance.toJson(); assertEquals(expResult, result); instance = new Value(3.0F); expResult = new FloatNode(3.0F); result = instance.toJson(); assertEquals(expResult, result); }
@Override public JsonNode toJson() { if (value instanceof Number) { if (value instanceof BigDecimal) { return getFactory().numberNode((BigDecimal) value); } else if (value instanceof BigInteger) { return getFactory().numberNode((BigInteger) value); } else if (value instanceof Double) { return getFactory().numberNode((Double) value); } else if (value instanceof Float) { return getFactory().numberNode((Float) value); } else if (value instanceof Long) { return getFactory().numberNode((Long) value); } else { return getFactory().numberNode(((Number) value).intValue()); } } else if (value instanceof Boolean) { return getFactory().booleanNode((Boolean) value); } else if (value == null) { return getFactory().nullNode(); } else if (value instanceof JsonNode) { return (JsonNode) value; } else { return getFactory().textNode(value.toString()); } }
Value extends JsonObject { @Override public JsonNode toJson() { if (value instanceof Number) { if (value instanceof BigDecimal) { return getFactory().numberNode((BigDecimal) value); } else if (value instanceof BigInteger) { return getFactory().numberNode((BigInteger) value); } else if (value instanceof Double) { return getFactory().numberNode((Double) value); } else if (value instanceof Float) { return getFactory().numberNode((Float) value); } else if (value instanceof Long) { return getFactory().numberNode((Long) value); } else { return getFactory().numberNode(((Number) value).intValue()); } } else if (value instanceof Boolean) { return getFactory().booleanNode((Boolean) value); } else if (value == null) { return getFactory().nullNode(); } else if (value instanceof JsonNode) { return (JsonNode) value; } else { return getFactory().textNode(value.toString()); } } }
Value extends JsonObject { @Override public JsonNode toJson() { if (value instanceof Number) { if (value instanceof BigDecimal) { return getFactory().numberNode((BigDecimal) value); } else if (value instanceof BigInteger) { return getFactory().numberNode((BigInteger) value); } else if (value instanceof Double) { return getFactory().numberNode((Double) value); } else if (value instanceof Float) { return getFactory().numberNode((Float) value); } else if (value instanceof Long) { return getFactory().numberNode((Long) value); } else { return getFactory().numberNode(((Number) value).intValue()); } } else if (value instanceof Boolean) { return getFactory().booleanNode((Boolean) value); } else if (value == null) { return getFactory().nullNode(); } else if (value instanceof JsonNode) { return (JsonNode) value; } else { return getFactory().textNode(value.toString()); } } Value(Object o); }
Value extends JsonObject { @Override public JsonNode toJson() { if (value instanceof Number) { if (value instanceof BigDecimal) { return getFactory().numberNode((BigDecimal) value); } else if (value instanceof BigInteger) { return getFactory().numberNode((BigInteger) value); } else if (value instanceof Double) { return getFactory().numberNode((Double) value); } else if (value instanceof Float) { return getFactory().numberNode((Float) value); } else if (value instanceof Long) { return getFactory().numberNode((Long) value); } else { return getFactory().numberNode(((Number) value).intValue()); } } else if (value instanceof Boolean) { return getFactory().booleanNode((Boolean) value); } else if (value == null) { return getFactory().nullNode(); } else if (value instanceof JsonNode) { return (JsonNode) value; } else { return getFactory().textNode(value.toString()); } } Value(Object o); Object getValue(); @Override JsonNode toJson(); static Value fromJson(JsonNode node); @Override int hashCode(); @Override boolean equals(Object obj); }
Value extends JsonObject { @Override public JsonNode toJson() { if (value instanceof Number) { if (value instanceof BigDecimal) { return getFactory().numberNode((BigDecimal) value); } else if (value instanceof BigInteger) { return getFactory().numberNode((BigInteger) value); } else if (value instanceof Double) { return getFactory().numberNode((Double) value); } else if (value instanceof Float) { return getFactory().numberNode((Float) value); } else if (value instanceof Long) { return getFactory().numberNode((Long) value); } else { return getFactory().numberNode(((Number) value).intValue()); } } else if (value instanceof Boolean) { return getFactory().booleanNode((Boolean) value); } else if (value == null) { return getFactory().nullNode(); } else if (value instanceof JsonNode) { return (JsonNode) value; } else { return getFactory().textNode(value.toString()); } } Value(Object o); Object getValue(); @Override JsonNode toJson(); static Value fromJson(JsonNode node); @Override int hashCode(); @Override boolean equals(Object obj);  }