@SuppressWarnings("unchecked")
    public static <N> N convertNumber(JsonNode node, Class<N> clazz) {
        if (node instanceof POJONode) {
            return convertNumber(DPathUtils.extractValue((POJONode) node), clazz);
        }
        if (clazz == Byte.class || clazz == byte.class) {
            byte value = node.isNumber() ? (byte) node.asInt()
                    : node.isTextual() ? Byte.parseByte(node.asText()) : 0;
            return (N) Byte.valueOf(value);
        }
        if (clazz == Short.class || clazz == short.class) {
            short value = node.isNumber() ? (short) node.asInt()
                    : node.isTextual() ? Short.parseShort(node.asText()) : 0;
            return (N) Short.valueOf(value);
        }
        if (clazz == Integer.class || clazz == int.class) {
            int value = node.isNumber() ? node.asInt()
                    : node.isTextual() ? Integer.parseInt(node.asText()) : 0;
            return (N) Integer.valueOf(value);
        }
        if (clazz == Long.class || clazz == long.class) {
            long value = node.isNumber() ? node.asLong()
                    : node.isTextual() ? Long.parseLong(node.asText()) : 0;
            return (N) Long.valueOf(value);
        }
        if (clazz == Float.class || clazz == float.class) {
            float value = node.isNumber() ? (float) node.asDouble()
                    : node.isTextual() ? Float.parseFloat(node.asText()) : 0;
            return (N) Float.valueOf(value);
        }
        if (clazz == Double.class || clazz == double.class) {
            double value = node.isNumber() ? node.asDouble()
                    : node.isTextual() ? Double.parseDouble(node.asText()) : 0;
            return (N) Double.valueOf(value);
        }
        if (clazz == BigInteger.class) {
            BigInteger value = node instanceof NumericNode ? ((NumericNode) node).bigIntegerValue()
                    : BigInteger.valueOf(node.isTextual() ? Long.parseLong(node.asText()) : 0);
            return (N) value;
        }
        if (clazz == BigDecimal.class) {
            BigDecimal value = node instanceof NumericNode ? ((NumericNode) node).decimalValue()
                    : BigDecimal.valueOf(node.isTextual() ? Double.parseDouble(node.asText()) : 0);
            return (N) value;
        }
        if (clazz == Number.class && node.isNumber()) {
            if (node.isIntegralNumber()) {
                return (N) Long.valueOf(node.asLong());
            }
            if (node.isFloatingPointNumber()) {
                return (N) Double.valueOf(node.asDouble());
            }
        }
        return null;
    }
@ SuppressWarnings ( "unchecked" ) public static < N > N convertNumber ( JsonNode node , Class < N > clazz ) { if ( node instanceof POJONode ) { return convertNumber ( DPathUtils . extractValue ( ( POJONode ) node ) , clazz ) ; } if ( clazz == Byte . class || clazz == byte . class ) { byte value = node . isNumber ( ) ? ( byte ) node . asInt ( ) : node . isTextual ( ) ? Byte . parseByte ( node . asText ( ) ) : 0 ; return ( N ) Byte . valueOf ( value ) ; } if ( clazz == Short . class || clazz == short . class ) { short value = node . isNumber ( ) ? ( short ) node . asInt ( ) : node . isTextual ( ) ? Short . parseShort ( node . asText ( ) ) : 0 ; return ( N ) Short . valueOf ( value ) ; } if ( clazz == Integer . class || clazz == int . class ) { int value = node . isNumber ( ) ? node . asInt ( ) : node . isTextual ( ) ? Integer . parseInt ( node . asText ( ) ) : 0 ; return ( N ) Integer . valueOf ( value ) ; } if ( clazz == Long . class || clazz == long . class ) { long value = node . isNumber ( ) ? node . asLong ( ) : node . isTextual ( ) ? Long . parseLong ( node . asText ( ) ) : 0 ; return ( N ) Long . valueOf ( value ) ; } if ( clazz == Float . class || clazz == float . class ) { float value = node . isNumber ( ) ? ( float ) node . asDouble ( ) : node . isTextual ( ) ? Float . parseFloat ( node . asText ( ) ) : 0 ; return ( N ) Float . valueOf ( value ) ; } if ( clazz == Double . class || clazz == double . class ) { double value = node . isNumber ( ) ? node . asDouble ( ) : node . isTextual ( ) ? Double . parseDouble ( node . asText ( ) ) : 0 ; return ( N ) Double . valueOf ( value ) ; } if ( clazz == BigInteger . class ) { BigInteger value = node instanceof NumericNode ? ( ( NumericNode ) node ) . bigIntegerValue ( ) : BigInteger . valueOf ( node . isTextual ( ) ? Long . parseLong ( node . asText ( ) ) : 0 ) ; return ( N ) value ; } if ( clazz == BigDecimal . class ) { BigDecimal value = node instanceof NumericNode ? ( ( NumericNode ) node ) . decimalValue ( ) : BigDecimal . valueOf ( node . isTextual ( ) ? Double . parseDouble ( node . asText ( ) ) : 0 ) ; return ( N ) value ; } if ( clazz == Number . class && node . isNumber ( ) ) { if ( node . isIntegralNumber ( ) ) { return ( N ) Long . valueOf ( node . asLong ( ) ) ; } if ( node . isFloatingPointNumber ( ) ) { return ( N ) Double . valueOf ( node . asDouble ( ) ) ; } } return null ; }
Convert a {@link JsonNode} to a specified number type.

<p>
This method will not return {@code null}. If {@code node} can not be converted to
{@code clazz},
{@code zero} will be return.
</p>

@param node
@param clazz
one of {@link Number}, {@link Byte}, {@link byte},
{@link Short}, {@link short}, {@link Integer}, {@link int},
{@link Long}, {@link long}, {@link Float}, {@link float},
{@link Double}, {@link double}, {@link BigInteger} or
{@link BigDecimal}
@return
@since 0.6.2