class NumberConverter implements PropertyConverter<Number> {

    @Override
    public Number convert(String value, ConversionContext ctx) {
        ctx.addSupportedFormats(getClass(), "<double>, <long>", "0x (hex)", "0X... (hex)", "POSITIVE_INFINITY",
                "NEGATIVE_INFINITY", "NAN");

        if(value==null){
            return null;
        }
        String trimmed = value.trim();
        switch(trimmed.toUpperCase(Locale.ENGLISH)) {
            case "POSITIVE_INFINITY":
                return Double.POSITIVE_INFINITY;
            case "NEGATIVE_INFINITY":
                return Double.NEGATIVE_INFINITY;
            case "NAN":
                return Double.NaN;
            default:
                Long lVal = longConverter.convert(trimmed, ctx);
                if (lVal != null) {
                    return lVal;
                }
                try {
                    return new BigDecimal(trimmed);
                } catch(Exception e) {
                    LOGGER.finest("Unparseable Number: " + trimmed);
                    return null;
                }
        }
    }

}