@Override public final double asDouble() { return doubleValue(); }
@Override public final int asInt() { return intValue(); }
@Override public final long asLong() { return longValue(); }
@Override public CoinbaseProCandle deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); TreeNode jo = mapper.readTree(jp); if (!jo.isArray() || jo.size() != 6) { throw new JsonMappingException(jp, "An array of length 6 expected: " + jo.toString()); } for (int i = 0; i < 6; i++) { if (!(jo.get(i) instanceof NumericNode)) { throw new JsonMappingException(jp, "Numeric values expected: " + jo.toString()); } } return new CoinbaseProCandle( new Date(((NumericNode) jo.get(0)).asLong() * 1000), new BigDecimal(((NumericNode) jo.get(3)).asText()), new BigDecimal(((NumericNode) jo.get(2)).asText()), new BigDecimal(((NumericNode) jo.get(1)).asText()), new BigDecimal(((NumericNode) jo.get(4)).asText()), new BigDecimal(((NumericNode) jo.get(5)).asText())); } }
public static Matcher<JsonNode> jsonNumber(final NumericNode value) { final JsonParser.NumberType numberType = value.numberType(); switch (numberType) { case INT: return jsonInt(value.asInt()); case LONG: return jsonLong(value.asLong()); case BIG_INTEGER: return jsonBigInteger(value.bigIntegerValue()); case FLOAT: return jsonFloat(value.floatValue()); case DOUBLE: return jsonDouble(value.doubleValue()); case BIG_DECIMAL: return jsonBigDecimal(value.decimalValue()); default: throw new UnsupportedOperationException("Unsupported number type " + numberType); } }
/** * @return The expected value for this condition. */ @JsonIgnore @Override public String getExpectedValue() { return expectedValue.asText(); }
BigInteger value = node instanceof NumericNode ? ((NumericNode) node).bigIntegerValue() : BigInteger.valueOf(node.isTextual() ? Long.parseLong(node.asText()) : 0); return (N) value; BigDecimal value = node instanceof NumericNode ? ((NumericNode) node).decimalValue() : BigDecimal.valueOf(node.isTextual() ? Double.parseDouble(node.asText()) : 0); return (N) value;
@Override public BigDecimal getValue() { return getJsonNode().decimalValue(); }
/** * @return The expected value for this condition. */ @JsonIgnore public String getExpectedValue() { return expectedValue.asText(); }
@Override public GDAXCandle deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); TreeNode jo = mapper.readTree(jp); if (!jo.isArray() || jo.size() != 6) { throw new JsonMappingException(jp, "An array of length 6 expected: " + jo.toString()); } for (int i = 0; i < 6; i++) { if (!(jo.get(i) instanceof NumericNode)) { throw new JsonMappingException(jp, "Numeric values expected: " + jo.toString()); } } return new GDAXCandle( new Date(((NumericNode) jo.get(0)).asLong() * 1000), new BigDecimal(((NumericNode) jo.get(3)).asText()), new BigDecimal(((NumericNode) jo.get(2)).asText()), new BigDecimal(((NumericNode) jo.get(1)).asText()), new BigDecimal(((NumericNode) jo.get(4)).asText()), new BigDecimal(((NumericNode) jo.get(5)).asText())); } }
@Override public final double asDouble(double defaultValue) { return doubleValue(); }
@Override public final int asInt(int defaultValue) { return intValue(); }
@Override public final long asLong(long defaultValue) { return longValue(); }
/** * @return The expected value for this condition. */ @JsonIgnore @Override public String getExpectedValue() { return expectedValue.asText(); }
@Override public final double asDouble() { return doubleValue(); } @Override
@Override public int asInt() { return intValue(); } @Override
@Override public final long asLong() { return longValue(); } @Override
/** * @return The expected value for this condition. */ @Override @JsonIgnore public String getExpectedValue() { return expectedValue.asText(); }
@Override public double asDouble(double defaultValue) { return doubleValue(); } }
@Override public final int asInt() { return intValue(); } @Override