protected int getRange(Object object) { if (!getters.contains("range")) { return 0; } try { Object rangeObj = null; rangeObj = getters.get("range").invoke(Object.class, object, object); if (rangeObj instanceof LazilyParsedNumber) { return ((LazilyParsedNumber)rangeObj).intValue(); } else if (rangeObj instanceof Double) { return (int)((Double)rangeObj + 0.5); } else if (rangeObj instanceof Integer) { return (Integer)rangeObj; } } catch (GetterException ex) { } return 0; }
public JsonElement read(JsonReader in) throws IOException { switch (in.peek()) { case NUMBER: return new JsonPrimitive(new LazilyParsedNumber(in.nextString())); case BOOLEAN: return new JsonPrimitive(Boolean.valueOf(in.nextBoolean())); case STRING: return new JsonPrimitive(in.nextString()); case NULL: in.nextNull(); return JsonNull.INSTANCE; case BEGIN_ARRAY: JsonElement array = new JsonArray(); in.beginArray(); while (in.hasNext()) { array.add(read(in)); } in.endArray(); return array; case BEGIN_OBJECT: JsonElement object = new JsonObject(); in.beginObject(); while (in.hasNext()) { object.add(in.nextName(), read(in)); } in.endObject(); return object; default: throw new IllegalArgumentException(); } }
public Number read(JsonReader in) throws IOException { JsonToken jsonToken = in.peek(); switch (jsonToken) { case NUMBER: return new LazilyParsedNumber(in.nextString()); case NULL: in.nextNull(); return null; default: throw new JsonSyntaxException("Expecting number, got: " + jsonToken); } }
@Override public Number read(JsonReader in) throws IOException { JsonToken jsonToken = in.peek(); switch (jsonToken) { case NULL: in.nextNull(); return null; case NUMBER: return new LazilyParsedNumber(in.nextString()); default: throw new JsonSyntaxException("Expecting number, got: " + jsonToken); } }
@Override public JsonElement read(JsonReader in) throws IOException { switch (in.peek()) { case STRING: return new JsonPrimitive(in.nextString()); case NUMBER: String number = in.nextString(); return new JsonPrimitive(new LazilyParsedNumber(number)); case BOOLEAN: return new JsonPrimitive(in.nextBoolean()); case NULL: in.nextNull(); return JsonNull.INSTANCE; case BEGIN_ARRAY: JsonArray array = new JsonArray(); in.beginArray(); while (in.hasNext()) { array.add(read(in)); } in.endArray(); return array; case BEGIN_OBJECT: JsonObject object = new JsonObject(); in.beginObject(); while (in.hasNext()) { object.add(in.nextName(), read(in)); } in.endObject(); return object; case END_DOCUMENT: case NAME: case END_OBJECT: case END_ARRAY: default: throw new IllegalArgumentException(); } }
@Override public Number read(JsonReader in) throws IOException { JsonToken jsonToken = in.peek(); switch (jsonToken) { case NULL: in.nextNull(); return null; case NUMBER: case STRING: return new LazilyParsedNumber(in.nextString()); default: throw new JsonSyntaxException("Expecting number, got: " + jsonToken); } }
@Nullable protected Number getAsNumber() { if (isString()) { return new LazilyParsedNumber((String) value); } else if (isNumber()) { return (Number) value; } else { return null; } }
public final Number getAsNumber() { if ((this.value instanceof String)) { return new LazilyParsedNumber((String)this.value); } return (Number)this.value; }
public Number getAsNumber() { if (b instanceof String) { return new LazilyParsedNumber((String)b); } else { return (Number)b; } }
private Object des(JsonElement val, JsonDeserializationContext context) { if (val.isJsonArray()) return MultimapAdapter.arraydes(val.getAsJsonArray(), context); else if (val.isJsonObject()) return context.deserialize(val, ASObject.class); else if (val.isJsonPrimitive()) { Object v = primConverter.convert(val.getAsJsonPrimitive()); if (v instanceof LazilyParsedNumber) v = new LazilyParsedNumberComparable((LazilyParsedNumber) v); return v; } else return null; }
@Override public Object invoke(Class<?> returnType, Object instance, Object... parameters) { if (returnType.equals(Integer.class)) { return (Object)((LazilyParsedNumber)constant).intValue(); } return constant; }