Example usage for com.fasterxml.jackson.databind.node ArrayNode ArrayNode

List of usage examples for com.fasterxml.jackson.databind.node ArrayNode ArrayNode

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node ArrayNode ArrayNode.

Prototype

public ArrayNode(JsonNodeFactory paramJsonNodeFactory) 

Source Link

Usage

From source file:io.fabric8.kubernetes.api.KubernetesHelper.java

/**
 * Combines the JSON objects into a config object
 *//*w w  w.  j  a  v  a2 s  . c  o m*/
public static JsonNode combineJson(Object... objects) throws IOException {
    JsonNode config = findOrCreateConfig(objects);
    JsonNode items = config.get("items");
    ArrayNode itemArray;
    if (items instanceof ArrayNode) {
        itemArray = (ArrayNode) items;
    } else {
        itemArray = new ArrayNode(createNodeFactory());
        if (config instanceof ObjectNode) {
            ObjectNode objectNode = (ObjectNode) config;
            objectNode.set("items", itemArray);
        } else {
            throw new IllegalArgumentException("config " + config + " is not a ObjectNode");
        }
    }
    for (Object object : objects) {
        if (object != config) {
            addObjectsToItemArray(itemArray, object);
        }
    }
    return config;
}