use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project jvm-serializers by eishay.
the class JacksonJsonTree method readMedia.
protected static Media readMedia(JsonNode node) {
Media media = new Media();
JsonNode bitrate = node.get("bitrate");
if (bitrate != null && !bitrate.isNull()) {
media.bitrate = bitrate.intValue();
media.hasBitrate = true;
}
media.copyright = node.path("copyright").textValue();
media.duration = node.path("duration").longValue();
media.format = node.path("format").textValue();
media.height = node.path("height").intValue();
media.player = Media.Player.valueOf(node.get("player").textValue());
ArrayNode personsArrayNode = (ArrayNode) node.get("persons");
int size = personsArrayNode.size();
List<String> persons = new ArrayList<String>(size);
for (JsonNode person : personsArrayNode) {
persons.add(person.textValue());
}
media.persons = persons;
media.size = node.get("size").intValue();
media.title = node.get("title").textValue();
media.uri = node.get("uri").textValue();
media.width = node.get("width").intValue();
return media;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project jvm-serializers by eishay.
the class JacksonJsonTree method addMedia.
protected static ObjectNode addMedia(Media media, ObjectNode node) {
if (media.hasBitrate) {
node.put("bitrate", media.bitrate);
}
node.put("copyright", media.copyright);
node.put("duration", media.duration);
node.put("format", media.format);
node.put("height", media.height);
ArrayNode persons = node.arrayNode();
for (String person : media.persons) {
persons.add(person);
}
node.set("persons", persons);
node.put("player", media.player.name());
node.put("size", media.size);
node.put("title", media.title);
node.put("uri", media.uri);
node.put("width", media.width);
return node;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project jvm-serializers by eishay.
the class JacksonJsonTree method readMediaContent.
protected static MediaContent readMediaContent(JsonNode root) throws IOException {
MediaContent mediaContent = new MediaContent();
mediaContent.media = readMedia(root.get("media"));
mediaContent.images = readImages((ArrayNode) root.get("images"));
return mediaContent;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project KaiZen-OpenAPI-Editor by RepreZen.
the class SwaggerSchema method allowJsonRefInContext.
public void allowJsonRefInContext(String jsonReferenceContext, boolean allow) {
if (jsonRefContexts.get(jsonReferenceContext) == null) {
throw new IllegalArgumentException("Invalid JSON Reference Context: " + jsonReferenceContext);
}
// special case
if (SwaggerPreferenceConstants.VALIDATION_REF_SECURITY_DEFINITIONS_OBJECT.equals(jsonReferenceContext)) {
allowJsonRefInSecurityDefinitionsObject(allow);
return;
}
ArrayNode definition = (ArrayNode) jsonRefContexts.get(jsonReferenceContext);
// should preserve order of the original ArrayNode._children
List<JsonNode> children = Lists.newArrayList(definition.elements());
int indexOfJsonReference = children.indexOf(refToJsonReferenceNode);
boolean alreadyHasJsonReference = indexOfJsonReference > -1;
if (allow) {
if (!alreadyHasJsonReference) {
definition.add(refToJsonReferenceNode.deepCopy());
}
} else {
// disallow
if (alreadyHasJsonReference) {
definition.remove(indexOfJsonReference);
}
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project KaiZen-OpenAPI-Editor by RepreZen.
the class MultipleSwaggerErrorBuilder method getHumanFriendlyText.
protected String getHumanFriendlyText(JsonNode swaggerSchemaNode, final String defaultValue) {
JsonNode title = swaggerSchemaNode.get("title");
if (title != null) {
return title.asText();
}
// nested array
if (swaggerSchemaNode.get("items") != null) {
return getHumanFriendlyText(swaggerSchemaNode.get("items"), defaultValue);
}
// "$ref":"#/definitions/headerParameterSubSchema"
JsonNode ref = swaggerSchemaNode.get("$ref");
if (ref != null) {
return getLabelForRef(ref.asText());
}
// Auxiliary oneOf in "oneOf": [ { "$ref": "#/definitions/securityRequirement" }]
JsonNode oneOf = swaggerSchemaNode.get("oneOf");
if (oneOf != null) {
if (oneOf instanceof ArrayNode) {
ArrayNode arrayNode = (ArrayNode) oneOf;
if (arrayNode.size() > 0) {
Iterator<String> labels = transform(arrayNode.elements(), new Function<JsonNode, String>() {
@Override
public String apply(JsonNode el) {
return getHumanFriendlyText(el, defaultValue);
}
});
return "[" + Joiner.on(", ").join(labels) + "]";
}
}
}
return defaultValue;
}
Aggregations