agave-jobs/jobs-core/src/test/java/org/iplantc/service/jobs/managers/JobRequestNotificationProcessorIT.java
/**
     * Sets an field in a ObjectNode object, determining the proper type on the fly.
     *
     * @param json  the object posted to the job reqeust
     * @param field the field to add to the object
     * @param value the value of the field
     * @return the updated ObjectNode
     */
Sets an field in a ObjectNode object, determining the proper type on the fly.
@param json  the object posted to the job reqeust
@param field the field to add to the object
@param value the value of the field
@return the updated ObjectNode
Sets an field in a ObjectNode object determining the proper type on the fly . @param json the object posted to the job reqeust @param field the field to add to the object @param value the value of the field @return the updated ObjectNode
private ObjectNode updateObjectNode(ObjectNode json, String field, Object value) {
        if (value == null)
            json.putNull(field);
        else if (value instanceof ArrayNode)
            json.putArray(field).addAll((ArrayNode) value);
        else if (value instanceof ObjectNode)
            json.putObject(field);
        else if (value instanceof Long)
            json.put(field, (Long) value);
        else if (value instanceof Integer)
            json.put(field, (Integer) value);
        else if (value instanceof Float)
            json.put(field, (Float) value);
        else if (value instanceof Double)
            json.put(field, (Double) value);
        else if (value instanceof BigDecimal)
            json.put(field, (BigDecimal) value);
        else if (value instanceof Boolean)
            json.put(field, (Boolean) value);
        else if (value instanceof Collection) {
            ArrayNode arrayNode = new ObjectMapper().createArrayNode();
            for (Object o : (Collection) value) {
                if (o instanceof ArrayNode)
                    arrayNode.addArray().addAll((ArrayNode) o);
                else if (o instanceof ObjectNode) {
                    assert value instanceof ObjectNode;
                    arrayNode.add((ObjectNode) value);
                } else if (o instanceof Long) {
                    assert value instanceof Long;
                    arrayNode.add((Long) value);
                } else if (o instanceof Integer) {
                    assert value instanceof Long;
                    arrayNode.add((Long) value);
                } else if (o instanceof Float) {
                    assert value instanceof Long;
                    arrayNode.add((Long) value);
                } else if (o instanceof Double) {
                    assert value instanceof Long;
                    arrayNode.add((Long) value);
                } else if (o instanceof Boolean) {
                    assert value instanceof Boolean;
                    arrayNode.add((Boolean) value);
                } else if (o instanceof String) {
                    assert value instanceof String;
                    arrayNode.add((String) value);
                } else
                    arrayNode.addObject();
            }
            json.putArray(field).addAll(arrayNode);
        } else if (value instanceof Map) {
            for (String key : ((Map<String, Object>) value).keySet()) {
                json = updateObjectNode(json, key, ((Map<String, Object>) value).get(key));
            }
        } else if (value instanceof String)
            json.put(field, (String) value);
        else
            json.putObject(field);
        return json;
    }
private ObjectNode updateObjectNode ( ObjectNode json , String field , Object value ) { if ( value == null ) json . putNull ( field ) ; else if ( value instanceof ArrayNode ) json . putArray ( field ) . addAll ( ( ArrayNode ) value ) ; else if ( value instanceof ObjectNode ) json . putObject ( field ) ; else if ( value instanceof Long ) json . put ( field , ( Long ) value ) ; else if ( value instanceof Integer ) json . put ( field , ( Integer ) value ) ; else if ( value instanceof Float ) json . put ( field , ( Float ) value ) ; else if ( value instanceof Double ) json . put ( field , ( Double ) value ) ; else if ( value instanceof BigDecimal ) json . put ( field , ( BigDecimal ) value ) ; else if ( value instanceof Boolean ) json . put ( field , ( Boolean ) value ) ; else if ( value instanceof Collection ) { ArrayNode arrayNode = new ObjectMapper ( ) . createArrayNode ( ) ; for ( Object o : ( Collection ) value ) { if ( o instanceof ArrayNode ) arrayNode . addArray ( ) . addAll ( ( ArrayNode ) o ) ; else if ( o instanceof ObjectNode ) { assert value instanceof ObjectNode ; arrayNode . add ( ( ObjectNode ) value ) ; } else if ( o instanceof Long ) { assert value instanceof Long ; arrayNode . add ( ( Long ) value ) ; } else if ( o instanceof Integer ) { assert value instanceof Long ; arrayNode . add ( ( Long ) value ) ; } else if ( o instanceof Float ) { assert value instanceof Long ; arrayNode . add ( ( Long ) value ) ; } else if ( o instanceof Double ) { assert value instanceof Long ; arrayNode . add ( ( Long ) value ) ; } else if ( o instanceof Boolean ) { assert value instanceof Boolean ; arrayNode . add ( ( Boolean ) value ) ; } else if ( o instanceof String ) { assert value instanceof String ; arrayNode . add ( ( String ) value ) ; } else arrayNode . addObject ( ) ; } json . putArray ( field ) . addAll ( arrayNode ) ; } else if ( value instanceof Map ) { for ( String key : ( ( Map < String , Object > ) value ) . keySet ( ) ) { json = updateObjectNode ( json , key , ( ( Map < String , Object > ) value ) . get ( key ) ) ; } } else if ( value instanceof String ) json . put ( field , ( String ) value ) ; else json . putObject ( field ) ; return json ; }
Sets an field in a ObjectNode object, determining the proper type on the fly.
Sets an field in a ObjectNode object determining the proper type on the fly .