private static void setNumericValue(String name, JsonNode node, Object obj, List<Method> setters) throws ReflectiveOperationException {

        //try numeric and equals first
        for (Method m : setters) {
            Class argClass = m.getParameters()[0].getType();
            if ((argClass.equals(int.class) || argClass.equals(Integer.class)) && node.isInt()) {
                m.invoke(obj, node.intValue());
                return;
            } else if ((argClass.equals(long.class) || argClass.equals(Long.class)) && node.isLong()) {
                m.invoke(obj, node.asLong());
                return;
            } else if ((argClass.equals(float.class) || argClass.equals(Float.class)) && node.isFloat()) {
                m.invoke(obj, node.floatValue());
                return;
            } else if ((argClass.equals(double.class) || argClass.equals(Double.class)) && node.isDouble()) {
                m.invoke(obj, node.doubleValue());
                return;
            } else if ((argClass.equals(short.class) || argClass.equals(Short.class)) && node.isShort()) {
                m.invoke(obj, node.shortValue());
                return;
            }
        }
        //try for higher precision setters
        for (Method m : setters) {
            Class argClass = m.getParameters()[0].getType();
            if ((argClass.equals(long.class) || argClass.equals(Long.class)) && node.isInt()) {
                m.invoke(obj, node.asLong());
                return;
            } else if ((argClass.equals(double.class) || argClass.equals(Double.class)) && node.isFloat()) {
                m.invoke(obj, node.floatValue());
                return;
            }
        }
        //try for lower precision setters
        //we have to do this for node=double, type=float; should we do this for long->integer?!
        for (Method m : setters) {
            Class argClass = m.getParameters()[0].getType();
            if ((argClass.equals(int.class) || argClass.equals(Integer.class)) && node.isLong()) {
                long val = node.longValue();
                if (val >= Integer.MAX_VALUE || val <= Integer.MIN_VALUE) {
                    //don't do this
                } else {
                    m.invoke(obj, node.intValue());
                }
                return;
            } else if ((argClass.equals(float.class) || argClass.equals(Float.class)) && node.isDouble()) {
                //TODO -- check for over/underflow
                m.invoke(obj, node.floatValue());
                return;
            } else if ((argClass.equals(short.class) || argClass.equals(Short.class)) && node.isInt()) {
                int val = node.intValue();
                if (val > Short.MAX_VALUE || val < Short.MIN_VALUE) {
                    //don't do this
                } else {
                    m.invoke(obj, node.shortValue());
                    return;
                }
            }
        }
        //finally try for String
        for (Method m : setters) {
            Class argClass = m.getParameters()[0].getType();
            if (argClass.equals(String.class)) {
                m.invoke(obj, node.asText());
                return;
            }
        }
        throw new IllegalArgumentException("Couldn't find numeric setter for: " + name);

    }
See the notes @link{TikaJsonSerializer}.
<p>
This currently requires a setString() option on objects that have enum parameters.
tika-serialization/src/main/java/org/apache/tika/serialization/TikaJsonDeserializer.java