return (T) id.getAsBigInteger();
@Test public void bigintegers_are_unwrapped() { final BigInteger bi = BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.TEN); final String json = "{bi-property = " + bi.toString() + "}"; JsonElement node = using(GSON_CONFIGURATION).parse(json).read("$.bi-property"); BigInteger val = using(GSON_CONFIGURATION).parse(json).read("$.bi-property", BigInteger.class); assertThat(val).isEqualTo(bi); assertThat(val).isEqualTo(node.getAsBigInteger()); }
@Test public void small_bigintegers_are_unwrapped() { final BigInteger bi = BigInteger.valueOf(Long.MAX_VALUE); final String json = "{bi-property = " + bi.toString() + "}"; JsonElement node = using(GSON_CONFIGURATION).parse(json).read("$.bi-property"); BigInteger val = using(GSON_CONFIGURATION).parse(json).read("$.bi-property", BigInteger.class); assertThat(val).isEqualTo(bi); assertThat(val).isEqualTo(node.getAsBigInteger()); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
/** * convenience method to get this array as a {@link BigInteger} if it contains a single element. * * @return get this element as a {@link BigInteger} if it is single element array. * @throws ClassCastException if the element in the array is of not a {@link JsonPrimitive}. * @throws NumberFormatException if the element at index 0 is not a valid {@link BigInteger}. * @throws IllegalStateException if the array has more than one element. * @since 1.2 */ @Override public BigInteger getAsBigInteger() { if (elements.size() == 1) { return elements.get(0).getAsBigInteger(); } throw new IllegalStateException(); }
@Override public void integerProperty(PropertyName name, JsonObject context) throws IOException { JsonElement prop = property(context, name); if (prop == null) { return; } builder.add(name, prop.getAsBigInteger()); }
public BigInteger deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { try { return json.getAsBigInteger(); } catch (NumberFormatException e) { throw new JsonSyntaxException(e); } catch (UnsupportedOperationException e) { throw new JsonSyntaxException(e); } catch (IllegalStateException e) { throw new JsonSyntaxException(e); } }
return (T) input.getAsBigDecimal(); } else if (expected == BigInteger.class) { return (T) input.getAsBigInteger(); } else if (Number.class.isAssignableFrom(expected)) {
return (T) id.getAsBigInteger();
return (T) input.getAsBigDecimal(); } else if (expected == BigInteger.class) { return (T) input.getAsBigInteger(); } else if (Number.class.isAssignableFrom(expected)) {