Search in sources :

Example 1 with LongNode

use of org.codehaus.jackson.node.LongNode in project neo4j by neo4j.

the class AbstractRESTInteraction method getValue.

private Object getValue(JsonNode valueNode) {
    Object value;
    if (valueNode instanceof TextNode) {
        value = valueNode.asText();
    } else if (valueNode instanceof ObjectNode) {
        value = mapValue(valueNode.getFieldNames(), valueNode);
    } else if (valueNode instanceof ArrayNode) {
        ArrayNode aNode = (ArrayNode) valueNode;
        ArrayList<String> listValue = new ArrayList<>(aNode.size());
        for (int j = 0; j < aNode.size(); j++) {
            listValue.add(aNode.get(j).asText());
        }
        value = listValue;
    } else if (valueNode instanceof IntNode) {
        value = valueNode.getIntValue();
    } else if (valueNode instanceof LongNode) {
        value = valueNode.getLongValue();
    } else if (valueNode.isNull()) {
        return null;
    } else {
        throw new RuntimeException(String.format("Unhandled REST value type '%s'. Need String (TextNode), List (ArrayNode), Object (ObjectNode), long (LongNode), or int (IntNode).", valueNode.getClass()));
    }
    return value;
}
Also used : IntNode(org.codehaus.jackson.node.IntNode) ObjectNode(org.codehaus.jackson.node.ObjectNode) ArrayList(java.util.ArrayList) TextNode(org.codehaus.jackson.node.TextNode) ArrayNode(org.codehaus.jackson.node.ArrayNode) Matchers.containsString(org.hamcrest.Matchers.containsString) LongNode(org.codehaus.jackson.node.LongNode)

Aggregations

ArrayList (java.util.ArrayList)1 ArrayNode (org.codehaus.jackson.node.ArrayNode)1 IntNode (org.codehaus.jackson.node.IntNode)1 LongNode (org.codehaus.jackson.node.LongNode)1 ObjectNode (org.codehaus.jackson.node.ObjectNode)1 TextNode (org.codehaus.jackson.node.TextNode)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1