class NumberType implements Type<NumberHolder> {

    @Override
    public NumberHolder convert(Object obj) {

        if (obj instanceof Number) {
            Number n = (Number) obj;
            BigDecimal result;

            if (n instanceof Double || n instanceof Float) {
                result = new BigDecimal(n.doubleValue());
            } else if (n instanceof BigDecimal) {
                result = (BigDecimal) n;
            } else if (n instanceof BigInteger) {
                result = new BigDecimal((BigInteger) n);
            } else {
                result = new BigDecimal(n.longValue());
            }

            return new NumberHolder(result);
        }

        if (obj == null) {
            return new NumberHolder(null);
        }

        if (obj instanceof String) {
            return decode((String) obj);
        }

        throw new IllegalArgumentException("conversion not supported for: " + obj.getClass());
    }

}