public static Label fromJson()

in src/main/java/com/amazonaws/services/neptune/propertygraph/Label.java [36:78]


    public static Label fromJson(JsonNode jsonNode) {
        if (jsonNode.isObject()) {

            String label = jsonNode.path("~label").textValue();

            Collection<String> fromLabels = new ArrayList<>();
            Collection<String> toLabels = new ArrayList<>();

            if (jsonNode.has("~fromLabels")) {
                JsonNode fromLabelsNode = jsonNode.path("~fromLabels");

                if (fromLabelsNode.isArray()) {
                    ArrayNode fromLabelsArrays = (ArrayNode) fromLabelsNode;
                    fromLabelsArrays.forEach(l -> fromLabels.add(l.textValue()));
                } else {
                    fromLabels.addAll(SemicolonUtils.split(fromLabelsNode.textValue()));
                }
            }

            if (jsonNode.has("~toLabels")) {
                JsonNode toLabelsNode = jsonNode.path("~toLabels");

                if (toLabelsNode.isArray()) {
                    ArrayNode toLabelsArray = (ArrayNode) toLabelsNode;
                    toLabelsArray.forEach(l -> toLabels.add(l.textValue()));
                } else {
                    toLabels.addAll(SemicolonUtils.split(toLabelsNode.textValue()));
                }
            }

            return new Label(Collections.singletonList(label), fromLabels, toLabels);
        } else {
            if (jsonNode.isArray()) {
                ArrayNode labelsNode = (ArrayNode) jsonNode;
                Collection<String> labels = new ArrayList<>();
                labelsNode.forEach(l -> labels.add(l.textValue()));
                return new Label(labels);
            } else {
                return new Label(jsonNode.textValue());
            }

        }
    }