/** * Use {@link #isBigDecimal()} to check first, if required. */ public BigDecimal asBigDecimal() { return asBigDecimal(null); }
@Override public ObjectAdapter asAdapter(JsonRepresentation repr, String format) { if (repr.isString()) { return adapterFor(new BigDecimal(repr.asString())); } if (repr.isBigDecimal()) { return adapterFor(repr.asBigDecimal(format)); } if (repr.isBigInteger()) { return adapterFor(new BigDecimal(repr.asBigInteger())); } if (repr.isDouble()) { return adapterFor(BigDecimal.valueOf(repr.asDouble())); } if (repr.isLong()) { return adapterFor(BigDecimal.valueOf(repr.asLong())); } if (repr.isInt()) { return adapterFor(BigDecimal.valueOf(repr.asInt())); } return null; } @Override
@Override public ObjectAdapter asAdapter(JsonRepresentation repr, String format) { if (repr.isString()) { return adapterFor(new BigDecimal(repr.asString())); } if (repr.isBigDecimal()) { return adapterFor(repr.asBigDecimal(format)); } if (repr.isBigInteger()) { return adapterFor(new BigDecimal(repr.asBigInteger())); } if (repr.isDouble()) { return adapterFor(BigDecimal.valueOf(repr.asDouble())); } if (repr.isLong()) { return adapterFor(BigDecimal.valueOf(repr.asLong())); } if (repr.isInt()) { return adapterFor(BigDecimal.valueOf(repr.asInt())); } return null; } @Override
@Override public ObjectAdapter asAdapter(JsonRepresentation repr, String format) { if (repr.isDouble()) { return adapterFor(repr.asDouble()); } if (repr.isLong()) { return adapterFor((double)repr.asLong()); } if (repr.isInt()) { return adapterFor((double)repr.asInt()); } if (repr.isBigInteger()) { return adapterFor(repr.asBigInteger().doubleValue()); } if (repr.isBigDecimal()) { return adapterFor(repr.asBigDecimal().doubleValue()); } if (repr.isNumber()) { return adapterFor(repr.asNumber().doubleValue()); } return null; } @Override
@Override public ObjectAdapter asAdapter(JsonRepresentation repr, String format) { if (repr.isDouble()) { return adapterFor(repr.asDouble()); } if (repr.isLong()) { return adapterFor((double)repr.asLong()); } if (repr.isInt()) { return adapterFor((double)repr.asInt()); } if (repr.isBigInteger()) { return adapterFor(repr.asBigInteger().doubleValue()); } if (repr.isBigDecimal()) { return adapterFor(repr.asBigDecimal().doubleValue()); } if (repr.isNumber()) { return adapterFor(repr.asNumber().doubleValue()); } return null; } @Override
final String argStr = "" + representation.asBigDecimal(); return encodableFacet.fromEncodedString(argStr);