Refine search
public static Set<String> gatherStringPropertyFromJsonNodes(Iterable<JsonNode> jsonNodes, String propertyName) { Set<String> result = new HashSet<String>(); // Using a Set to filter out doubles for (JsonNode node : jsonNodes) { if (node.has(propertyName)) { String propertyValue = node.get(propertyName).asText(); if (propertyValue != null) { // Just to be safe result.add(propertyValue); } } } return result; }
public static List<JsonNode> getAppModelReferencedProcessModels(JsonNode appModelJson) { List<JsonNode> result = new ArrayList<JsonNode>(); if (appModelJson.has("models")) { ArrayNode modelsArrayNode = (ArrayNode) appModelJson.get("models"); Iterator<JsonNode> modelArrayIterator = modelsArrayNode.iterator(); while (modelArrayIterator.hasNext()) { result.add(modelArrayIterator.next()); } } return result; }
/** * Get a String field from the JSON. * * @param json JSON document. * @param fieldName Field name to get. * @return String value of field or null if not present. */ private String getTextField(JsonNode json, String fieldName) { if (!json.has(fieldName)) { return null; } return json.get(fieldName).asText(); }
public String getClassName(String propertyName, JsonNode node) { if (node != null) { if (node.has("javaName")) { propertyName = node.get("javaName").textValue(); } else if (generationConfig.isUseTitleAsClassname() && node.has("title")) { String title = node.get("title").textValue(); propertyName = WordUtils.capitalize(title).replaceAll(" ", ""); } } return propertyName; }
@Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && (node.has("minLength") || node.has("maxLength"))) { JAnnotationUse annotation = field.annotate(Size.class); if (node.has("minLength")) { annotation.param("min", node.get("minLength").asInt()); } if (node.has("maxLength")) { annotation.param("max", node.get("maxLength").asInt()); } } return field; }
@Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && (node.has("minItems") || node.has("maxItems"))) { JAnnotationUse annotation = field.annotate(Size.class); if (node.has("minItems")) { annotation.param("min", node.get("minItems").asInt()); } if (node.has("maxItems")) { annotation.param("max", node.get("maxItems").asInt()); } } return field; }
/** * Returns the JType for an integer field. Handles type lookup and unboxing. */ private JType getIntegerType(JCodeModel owner, JsonNode node, GenerationConfig config) { if (config.isUseBigIntegers()) { return unboxIfNecessary(owner.ref(BigInteger.class), config); } else if (config.isUseLongIntegers() || node.has("minimum") && node.get("minimum").isLong() || node.has("maximum") && node.get("maximum").isLong()) { return unboxIfNecessary(owner.ref(Long.class), config); } else { return unboxIfNecessary(owner.ref(Integer.class), config); } }