@Override public Object serialize(Object dataFetcherResult) { if (dataFetcherResult instanceof IntNode) { return ((IntNode) dataFetcherResult).numberValue(); } else { throw serializationException(dataFetcherResult, IntNode.class); } }
/** * Traverse an ArrayNode and convert to ArrayList * * @param n. A Jackson ArrayNode. * @return List. The list that corresponds to the Jackson ArrayNode. */ List traverse(ArrayNode n) { List list = new ArrayList(); for (int i = 0; i < n.size(); i++) { Object obj = n.get(i); if (obj instanceof IntNode) { IntNode d = (IntNode) obj; list.add(d.numberValue()); } else if (obj instanceof DoubleNode) { DoubleNode d = (DoubleNode) obj; list.add(d.numberValue()); } else { TextNode t = (TextNode) obj; list.add(t.textValue()); } } return list; }
if (obj instanceof IntNode) { IntNode d = (IntNode) obj; list.add(d.numberValue()); } else if (obj instanceof DoubleNode) { DoubleNode d = (DoubleNode) obj;
/** * Iterate over a Jackson object and create a Java Map. * * @param node. ObjectNode. The Jackson node to set up as a Map. * @return Map. Returns the Map implementation of the Jackson node. */ Map iterateObject(ObjectNode node) { Map m = new HashMap(); Iterator it = node.iterator(); it = node.fieldNames(); while (it.hasNext()) { String key = (String) it.next(); Object s = node.get(key); if (s instanceof TextNode) { TextNode t = (TextNode) s; m.put(key, t.textValue()); } else if (s instanceof DoubleNode) { DoubleNode t = (DoubleNode) s; m.put(key, t.numberValue()); } else if (s instanceof IntNode) { IntNode t = (IntNode) s; m.put(key, t.numberValue()); } else m.put(key, s); // indeterminate, need to traverse } return m; }
/** * Iterate over a Jackson object and create a Java Map. * * @param node. * ObjectNode. The Jackson node to set up as a Map. * @return Map. Returns the Map implementation of the Jackson node. */ Map iterateObject(ObjectNode node) { Map m = new HashMap(); Iterator it = node.iterator(); it = node.fieldNames(); while (it.hasNext()) { String key = (String) it.next(); Object s = node.get(key); if (s instanceof TextNode) { TextNode t = (TextNode) s; m.put(key, t.textValue()); } else if (s instanceof DoubleNode) { DoubleNode t = (DoubleNode) s; m.put(key, t.numberValue()); } else if (s instanceof IntNode) { IntNode t = (IntNode) s; m.put(key, t.numberValue()); } else m.put(key, s); // indeterminate, need to traverse } return m; }
if (value instanceof IntNode) { IntNode n = (IntNode) value; nvalue = n.numberValue(); } else if (value instanceof TextNode) { TextNode tn = (TextNode) value; } else if (value instanceof Integer) { IntNode n = new IntNode((Integer) value); // (Node) value; nvalue = n.numberValue(); } else if (value instanceof Collection) { qvalue = new TreeSet();