/** * Method that will construct an ArrayNode and add it at the end * of this array node. * * @return Newly constructed ArrayNode */ public ArrayNode addArray() { ArrayNode n = arrayNode(); _add(n); return n; }
/** * Method for creating an array node, inserting it at the * specified point in the array, * and returning the <b>newly created array</b> * (note: NOT 'this' array) */ public ArrayNode insertArray(int index) { ArrayNode n = arrayNode(); _insert(index, n); return n; }
/** * Method for creating an array node, inserting it at the * specified point in the array, * and returning the <b>newly created array</b> * (note: NOT 'this' array) */ public ArrayNode insertArray(int index) { ArrayNode n = arrayNode(); _insert(index, n); return n; }
/** * Method for creating an array node, inserting it at the * specified point in the array, * and returning the <b>newly created array</b> * (note: NOT 'this' array) */ public ArrayNode insertArray(int index) { ArrayNode n = arrayNode(); _insert(index, n); return n; }
/** * Method that will construct an ArrayNode and add it as a * field of this ObjectNode, replacing old value, if any. * * @return Newly constructed ArrayNode */ public ArrayNode addArray() { ArrayNode n = arrayNode(); _add(n); return n; }
/** * Method that will construct an ArrayNode and add it as a * field of this ObjectNode, replacing old value, if any. * * @return Newly constructed ArrayNode */ public ArrayNode addArray() { ArrayNode n = arrayNode(); _add(n); return n; }
/** * Method for creating an array node, inserting it at the * specified point in the array, * and returning the <b>newly created array</b> * (note: NOT 'this' array) */ public ArrayNode insertArray(int index) { ArrayNode n = arrayNode(); _insert(index, n); return n; }
/** * Method that will construct an ArrayNode and add it at the end * of this array node. * * @return Newly constructed ArrayNode */ public ArrayNode addArray() { ArrayNode n = arrayNode(); _add(n); return n; }
/** * Method that will construct an ArrayNode and add it as a * field of this ObjectNode, replacing old value, if any. * * @return Newly constructed ArrayNode */ public ArrayNode addArray() { ArrayNode n = arrayNode(); _add(n); return n; }
/** * Method for creating an array node, inserting it at the * specified point in the array, * and returning the <b>newly created array</b> * (note: NOT 'this' array) */ public ArrayNode insertArray(int index) { ArrayNode n = arrayNode(); _insert(index, n); return n; }
/** * Method for creating an array node, inserting it at the * specified point in the array, * and returning the <b>newly created array</b> * (note: NOT 'this' array) */ public ArrayNode insertArray(int index) { ArrayNode n = arrayNode(); _insert(index, n); return n; }
/** * Method that will construct an ArrayNode and add it as a * field of this ObjectNode, replacing old value, if any. * * @return Newly constructed ArrayNode */ public ArrayNode addArray() { ArrayNode n = arrayNode(); _add(n); return n; }
/** * Method for creating an array node, inserting it at the * specified point in the array, * and returning the <b>newly created array</b> * (note: NOT 'this' array) */ public ArrayNode insertArray(int index) { ArrayNode n = arrayNode(); _insert(index, n); return n; }
/** * Method that will construct an ArrayNode and add it as a * field of this ObjectNode, replacing old value, if any. * * @return Newly constructed ArrayNode */ public ArrayNode addArray() { ArrayNode n = arrayNode(); _add(n); return n; }
public static ArrayNode resolveSecrets(ArrayNode node, SecretProvider secrets) { ArrayNode newNode = node.arrayNode(); node.elements().forEachRemaining(element -> newNode.add(resolveSecrets(element, secrets))); return newNode; }
@Override public JsonNode visitArray(ArrayNode arrayNode) { ArrayNode newArrayNode = arrayNode.arrayNode(); int index = 0; for (JsonNode node : arrayNode) { try { newArrayNode.add(JsonNodeVisitors.dispatch(node, this)); } catch (StringSubstitutionException e) { throw e.extend(index); } index++; } return newArrayNode; }
private static JsonNode deepCopyArray(ArrayNode node, IdentityHashMap<JsonNode, JsonNode> copies) { ArrayNode copy = node.arrayNode(); copies.put(node, copy); for (JsonNode element : iterable(node.elements())) { copy.add(deepCopy(element, copies)); } return copy; } }
private ArrayNode evalArrayRecursive(ArrayNode array) throws IOException { ArrayNode built = array.arrayNode(); for (JsonNode value : array) { JsonNode evaluated; if (value.isObject()) { evaluated = evalObjectRecursive((ObjectNode) value); } else if (value.isArray()) { evaluated = evalArrayRecursive((ArrayNode) value); } else if (value.isTextual() && value.textValue().startsWith("!include:")) { evaluated = include(value.textValue()); } else { evaluated = value; } built.add(evaluated); } return built; }
private static JsonNode resolveSecrets(JsonNode node, SecretProvider secrets) { if (node.isObject()) { ObjectNode object = (ObjectNode) node; ObjectNode newObject = object.objectNode(); object.fields().forEachRemaining(entry -> newObject.set( UserSecretTemplate.of(entry.getKey()).format(secrets), resolveSecrets(entry.getValue(), secrets))); return newObject; } else if (node.isArray()) { ArrayNode array = (ArrayNode) node; ArrayNode newArray = array.arrayNode(); array.elements().forEachRemaining(element -> newArray.add(resolveSecrets(element, secrets))); return newArray; } else if (node.isTextual()) { return new TextNode(UserSecretTemplate.of(node.textValue()).format(secrets)); } else { return node; } }
/** * Apply a migrator to all elements of the array at the current pointer * * <p>Note that if the migrator fails to apply to at least one element, the * original array is left untouched; its elements are replaced if and only * if the migrator applies successfully to <strong>all</strong> elements. * </p> * * @param migrator the migrator to apply * @throws SwaggerMigrationException current node is not a JSON Array, or * migrator failed to apply to at least one array element */ public void applyMigratorToElements(final SwaggerMigrator migrator) throws SwaggerMigrationException { if (!currentNode.isArray()) { throw new SwaggerMigrationException(); } final ArrayNode array = (ArrayNode) currentNode; final ArrayNode transformed = array.arrayNode(); for (final JsonNode element : array) { transformed.add(migrator.migrate(element)); } array.removeAll().addAll(transformed); }