private void assureReference(final JsonNode schemaNode, final Schema schema, final JPackage classPackage) { if (schemaNode.isObject()) { final ObjectNode oNode = (ObjectNode) schemaNode; if (oNode.get("properties") instanceof ObjectNode) { final ObjectNode propsNode = (ObjectNode) oNode.get("properties"); for (final ObjectNode singlePropsNode : FluentIterable.from(Lists.newArrayList(propsNode.iterator())) .filter(ObjectNode.class)) { assureRef(singlePropsNode, schema, classPackage); } } } }
/** * 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; }