use of com.massivecraft.massivecore.xlib.gson.internal.LazilyParsedNumber in project MassiveCore by MassiveCraft.
the class GsonMongoConverter method gson2MongoPrimitive.
public static Object gson2MongoPrimitive(JsonElement inElement) {
if (inElement.isJsonNull())
return null;
JsonPrimitive in = inElement.getAsJsonPrimitive();
if (in.isBoolean()) {
return in.getAsBoolean();
}
if (in.isNumber()) {
Number number = in.getAsNumber();
boolean floating;
if (number instanceof LazilyParsedNumber) {
floating = StringUtils.contains(number.toString(), '.');
} else {
floating = (number instanceof Double || number instanceof Float);
}
if (floating) {
return number.doubleValue();
} else {
return number.longValue();
}
}
if (in.isString()) {
return in.getAsString();
}
throw new IllegalArgumentException("Unsupported value type for: " + in);
}
Aggregations