Java Code Examples for com.fasterxml.jackson.databind.node.ArrayNode#arrayNode()

The following examples show how to use com.fasterxml.jackson.databind.node.ArrayNode#arrayNode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpOperatorFactory.java    From digdag with Apache License 2.0 6 votes vote down vote up
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;
    }
}
 
Example 2
Source File: ConfigEvalEngine.java    From digdag with Apache License 2.0 6 votes vote down vote up
private ArrayNode evalArrayRecursive(ObjectNode local, ArrayNode array)
    throws TemplateException
{
    ArrayNode built = array.arrayNode();
    for (JsonNode value : array) {
        JsonNode evaluated;
        if (value.isObject()) {
            evaluated = evalObjectRecursive((ObjectNode) value);
        }
        else if (value.isArray()) {
            evaluated = evalArrayRecursive(local, (ArrayNode) value);
        }
        else if (value.isTextual()) {
            // eval using template engine
            String code = value.textValue();
            evaluated = evalValue(local, code);
        }
        else {
            evaluated = value;
        }
        built.add(evaluated);
    }
    return built;
}
 
Example 3
Source File: YamlConfigLoader.java    From digdag with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: Secrets.java    From digdag with Apache License 2.0 4 votes vote down vote up
public static ArrayNode resolveSecrets(ArrayNode node, SecretProvider secrets)
{
    ArrayNode newNode = node.arrayNode();
    node.elements().forEachRemaining(element -> newNode.add(resolveSecrets(element, secrets)));
    return newNode;
}