@Test public void testFromJson() throws IOException { Value expResult = new Value(10L); JsonNode longNode = new LongNode(10); Value result = Value.fromJson(longNode); assertEquals(expResult, result); assertEquals("[\"test\"]", Value.fromJson(JsonUtils.json("[\"test\"]")).toJson().toString()); }
public static Value fromJson(JsonNode node) { if (node instanceof NullNode) { return new Value(null); } else if (node instanceof ObjectNode || node instanceof ArrayNode) { return new Value(node); } else if (node.isValueNode()) { Object v; if (node.isNumber()) { if (node.isBigDecimal() || node.isDouble() || node.isFloat()) { v = node.decimalValue(); } else if (node.isBigInteger()) { v = node.bigIntegerValue(); } else if (node.isLong()) { v = node.longValue(); } else { v = node.intValue(); } } else if (node.isBoolean()) { v = node.booleanValue(); } else { v = node.textValue(); } return new Value(v); } else { throw Error.get(QueryConstants.ERR_INVALID_VALUE, node.toString()); } }
Value extends JsonObject { public static Value fromJson(JsonNode node) { if (node instanceof NullNode) { return new Value(null); } else if (node instanceof ObjectNode || node instanceof ArrayNode) { return new Value(node); } else if (node.isValueNode()) { Object v; if (node.isNumber()) { if (node.isBigDecimal() || node.isDouble() || node.isFloat()) { v = node.decimalValue(); } else if (node.isBigInteger()) { v = node.bigIntegerValue(); } else if (node.isLong()) { v = node.longValue(); } else { v = node.intValue(); } } else if (node.isBoolean()) { v = node.booleanValue(); } else { v = node.textValue(); } return new Value(v); } else { throw Error.get(QueryConstants.ERR_INVALID_VALUE, node.toString()); } } }
Value extends JsonObject { public static Value fromJson(JsonNode node) { if (node instanceof NullNode) { return new Value(null); } else if (node instanceof ObjectNode || node instanceof ArrayNode) { return new Value(node); } else if (node.isValueNode()) { Object v; if (node.isNumber()) { if (node.isBigDecimal() || node.isDouble() || node.isFloat()) { v = node.decimalValue(); } else if (node.isBigInteger()) { v = node.bigIntegerValue(); } else if (node.isLong()) { v = node.longValue(); } else { v = node.intValue(); } } else if (node.isBoolean()) { v = node.booleanValue(); } else { v = node.textValue(); } return new Value(v); } else { throw Error.get(QueryConstants.ERR_INVALID_VALUE, node.toString()); } } Value(Object o); }
Value extends JsonObject { public static Value fromJson(JsonNode node) { if (node instanceof NullNode) { return new Value(null); } else if (node instanceof ObjectNode || node instanceof ArrayNode) { return new Value(node); } else if (node.isValueNode()) { Object v; if (node.isNumber()) { if (node.isBigDecimal() || node.isDouble() || node.isFloat()) { v = node.decimalValue(); } else if (node.isBigInteger()) { v = node.bigIntegerValue(); } else if (node.isLong()) { v = node.longValue(); } else { v = node.intValue(); } } else if (node.isBoolean()) { v = node.booleanValue(); } else { v = node.textValue(); } return new Value(v); } else { throw Error.get(QueryConstants.ERR_INVALID_VALUE, node.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 { public static Value fromJson(JsonNode node) { if (node instanceof NullNode) { return new Value(null); } else if (node instanceof ObjectNode || node instanceof ArrayNode) { return new Value(node); } else if (node.isValueNode()) { Object v; if (node.isNumber()) { if (node.isBigDecimal() || node.isDouble() || node.isFloat()) { v = node.decimalValue(); } else if (node.isBigInteger()) { v = node.bigIntegerValue(); } else if (node.isLong()) { v = node.longValue(); } else { v = node.intValue(); } } else if (node.isBoolean()) { v = node.booleanValue(); } else { v = node.textValue(); } return new Value(v); } else { throw Error.get(QueryConstants.ERR_INVALID_VALUE, node.toString()); } } Value(Object o); Object getValue(); @Override JsonNode toJson(); static Value fromJson(JsonNode node); @Override int hashCode(); @Override boolean equals(Object obj);  }