Java Code Examples for com.fasterxml.jackson.databind.JsonNode#fields()

The following examples show how to use com.fasterxml.jackson.databind.JsonNode#fields() . 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: PropertiesCollectionResourceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * Test getting the engine properties.
 */
public void testGetProperties() throws Exception {
  CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROPERTIES_COLLECTION)), HttpStatus.SC_OK);

  Map<String, String> properties = managementService.getProperties();

  JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
  closeResponse(response);
  assertNotNull(responseNode);
  assertEquals(properties.size(), responseNode.size());

  Iterator<Map.Entry<String, JsonNode>> nodes = responseNode.fields();
  Map.Entry<String, JsonNode> node = null;
  while (nodes.hasNext()) {
    node = nodes.next();
    String propValue = properties.get(node.getKey());
    assertNotNull(propValue);
    assertEquals(propValue, node.getValue().textValue());
  }
}
 
Example 2
Source File: ObjectTypeDefinition.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 6 votes vote down vote up
protected void initProperties(String container, Map<String, TypeDefinition> properties) {
    if (content.has(container) && content.get(container).isObject()) {

        JsonNode node = content.get(container);
        if (JsonReference.isReference(node)) {
            node = schema.resolve(JsonReference.getPointer(node));
        }

        for (Iterator<Entry<String, JsonNode>> it = node. fields(); it.hasNext();) {
            Entry<String, JsonNode> e = it.next();

            String property = e.getKey().replaceAll("/", "~1");
            TypeDefinition type = schema.createType(this, container + "/" + property, e.getValue());
            if (type != null) {
                properties.put(e.getKey(), type);
            }
        }
    }
}
 
Example 3
Source File: ParameterIOUtilities.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Convert the contents of a JSON "plugins" node to a per-plugin key:value
 * map.
 * <p>
 * The JSON object looks like:
 * <pre>
 *      plugina.param1: value,
 *      plugina.param2: value,
 *      pluginb.param1: value,
 *      pluginc.param1: value
 * </pre> Build a Map mapping plugin names to Maps of param key:values.
 *
 * @param pluginsNode
 * @return
 */
private static Map<String, Map<String, String>> toPerPluginParamMap(final JsonNode pluginsNode) {
    final Map<String, Map<String, String>> pluginMap = new HashMap<>();
    for (final Iterator<Map.Entry<String, JsonNode>> i = pluginsNode.fields(); i.hasNext();) {
        final Map.Entry<String, JsonNode> entry = i.next();
        final String name = entry.getKey();
        final String value = entry.getValue().textValue();

        final int ix = name.indexOf('.');
        if (ix != -1) {
            final String plugin = name.substring(0, ix);
            if (!pluginMap.containsKey(plugin)) {
                pluginMap.put(plugin, new HashMap<>());
            }

            pluginMap.get(plugin).put(name, value);
        }
    }

    return pluginMap;
}
 
Example 4
Source File: JsonObjectMapperDecoder.java    From ffwd with Apache License 2.0 6 votes vote down vote up
private Map<String, String> decodeAttributes(JsonNode tree, String name) {
    final JsonNode n = tree.get(name);

    if (n == null) {
        return EMPTY_ATTRIBUTES;
    }

    if (n.getNodeType() != JsonNodeType.OBJECT) {
        return EMPTY_ATTRIBUTES;
    }

    final Map<String, String> attributes = Maps.newHashMap();

    final Iterator<Map.Entry<String, JsonNode>> iter = n.fields();

    while (iter.hasNext()) {
        final Map.Entry<String, JsonNode> e = iter.next();
        attributes.put(e.getKey(), e.getValue().asText());
    }

    return attributes;
}
 
Example 5
Source File: DynamoDSETranslatorJSONBlob.java    From dynamo-cassandra-proxy with Apache License 2.0 6 votes vote down vote up
private Map<String, AttributeValue> blobToItemSet(String json_blob) throws IOException
{
    JsonNode items = awsRequestMapper.readTree(json_blob);

    Map<String, AttributeValue> itemSet = new HashMap<>();

    List<String> dynamoTypes = Arrays.asList("N", "S", "BOOL", "B", "S", "SS");
    Iterator<Map.Entry<String, JsonNode>> fieldIterator = items.fields();

    for (Iterator<Map.Entry<String, JsonNode>> it = fieldIterator; it.hasNext(); ) {
        Map.Entry<String, JsonNode> item = it.next();
        Iterator<Map.Entry<String, JsonNode>> itemFieldIterator = item.getValue().fields();
        for (Iterator<Map.Entry<String, JsonNode>> it2 = itemFieldIterator; it2.hasNext(); ) {
            Map.Entry<String, JsonNode> pair = it2.next();
            if (!dynamoTypes.contains(pair.getKey())) {
                throw new UnsupportedOperationException("Nested not implemented");
            } else {
                itemSet.put(item.getKey(), getAttributeFromJsonLeaf(item.getValue(), pair.getKey()));
            }
        }
    }
    return itemSet;
}
 
Example 6
Source File: PlainJsonDocumentDeserializer.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
private Resource deserializeResource(JsonNode data, Map<ResourceIdentifier, Resource> included) {
	Resource resource = new Resource();

	resource.setId(SerializerUtil.readStringIfExists("id", data));
	resource.setType(SerializerUtil.readStringIfExists("type", data));
	resource.setMeta((ObjectNode) data.get("meta"));
	resource.setLinks((ObjectNode) data.get("links"));

	Iterator<Map.Entry<String, JsonNode>> fields = data.fields();
	while (fields.hasNext()) {
		Map.Entry<String, JsonNode> entry = fields.next();
		String fieldName = entry.getKey();
		if (!SYSTEM_FIELDS.contains(fieldName)) {
			JsonNode fieldValue = entry.getValue();
			deserializeField(fieldName, fieldValue, resource, included);
		}
	}
	return resource;
}
 
Example 7
Source File: PropertiesCollectionResourceTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
/**
 * Test getting the engine properties.
 */
@Test
public void testGetProperties() throws Exception {
    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROPERTIES_COLLECTION)),
            HttpStatus.SC_OK);

    Map<String, String> properties = managementService.getProperties();

    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertThat(responseNode).isNotNull();
    assertThat(responseNode).hasSize(properties.size());

    Iterator<Map.Entry<String, JsonNode>> nodes = responseNode.fields();
    Map.Entry<String, JsonNode> node = null;
    while (nodes.hasNext()) {
        node = nodes.next();
        String propValue = properties.get(node.getKey());
        assertThat(propValue).isNotNull();
        assertThat(node.getValue().textValue()).isEqualTo(propValue);
    }
}
 
Example 8
Source File: JsonUtils.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
private static void updateObject(JsonNode target,
                                 ValueNode value,
                                 Map.Entry<String, JsonNode> src) {
    boolean newEntry = true;
    Iterator<Map.Entry<String, JsonNode>> iter = target.fields();
    while (iter.hasNext()) {
        Map.Entry<String, JsonNode> entry = iter.next();
        if (entry.getKey().equals(src.getKey())) {
            newEntry = false;
            entry.setValue(value);
        }
    }
    if (newEntry) {
        ((ObjectNode) target).replace(src.getKey(), src.getValue());
    }
}
 
Example 9
Source File: RosettaBinder.java    From Rosetta with Apache License 2.0 6 votes vote down vote up
public void bind(String prefix, JsonNode node, Callback callback) {
  for (Iterator<Entry<String, JsonNode>> iterator = node.fields(); iterator.hasNext(); ) {
    Entry<String, JsonNode> field = iterator.next();
    String key = prefix.isEmpty() ? field.getKey() : prefix + "." + field.getKey();
    JsonNode value = field.getValue();

    if (value.isObject()) {
      bind(key, value, callback);
    } else if (value.isArray()) {
      List<Object> elements = new ArrayList<>();
      for (JsonNode element : value) {
        elements.add(unwrapJsonValue(element));
      }

      callback.bind(key, elements);
    } else {
      callback.bind(key, unwrapJsonValue(value));
    }
  }
}
 
Example 10
Source File: IntegrationExportSource.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, OpenApi> getOpenApis() {
    Map<String, OpenApi> openApis = new HashMap<>();

    try {
        JsonNode apis = model.get("open-apis");
        if (apis != null) {
            Iterator<Map.Entry<String, JsonNode>> fields = apis.fields();
            while (fields.hasNext()) {
                Map.Entry<String, JsonNode> fieldEntry = fields.next();
                openApis.put(fieldEntry.getKey(), JsonUtils.reader().forType(OpenApi.class).readValue(fieldEntry.getValue()));
            }
        }
    } catch (IOException e) {
        throw new IllegalStateException("Failed to read open apis from export", e);
    }

    return openApis;
}
 
Example 11
Source File: HalRelationCacheConfiguration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void parseCacheConfigurations(JsonNode jsonConfiguration) {
  JsonNode jsonNode = jsonConfiguration.get(CONFIG_CACHES);
  if (jsonNode != null) {
    Iterator<Entry<String, JsonNode>> cacheConfigurations = jsonNode.fields();
    while (cacheConfigurations.hasNext()) {
      Entry<String, JsonNode> cacheConfiguration = cacheConfigurations.next();
      parseCacheConfiguration(cacheConfiguration.getKey(), cacheConfiguration.getValue());
    }
  }
}
 
Example 12
Source File: Attribute.java    From zentity with Apache License 2.0 5 votes vote down vote up
/**
 * Deserialize, validate, and hold the state of an attribute object of an entity model.
 * Expected structure of the json variable:
 * <pre>
 * {
 *   "type": ATTRIBUTE_TYPE
 * }
 * </pre>
 *
 * @param json Attribute object of an entity model.
 * @throws ValidationException
 * @throws JsonProcessingException
 */
public void deserialize(JsonNode json) throws ValidationException, JsonProcessingException {
    validateObject(json);

    // Validate and hold the state of fields.
    Iterator<Map.Entry<String, JsonNode>> fields = json.fields();
    while (fields.hasNext()) {
        Map.Entry<String, JsonNode> field = fields.next();
        String name = field.getKey();
        JsonNode value = field.getValue();
        switch (name) {
            case "type":
                this.type(value);
                break;
            case "params":
                // Set any params that were specified in the input, with the values serialized as strings.
                if (!value.isObject())
                    throw new ValidationException("'attributes." + this.name + ".params' must be an object.");
                Iterator<Map.Entry<String, JsonNode>> paramsNode = value.fields();
                while (paramsNode.hasNext()) {
                    Map.Entry<String, JsonNode> paramNode = paramsNode.next();
                    String paramField = paramNode.getKey();
                    JsonNode paramValue = paramNode.getValue();
                    if (paramValue.isObject() || paramValue.isArray())
                        this.params().put(paramField, Json.MAPPER.writeValueAsString(paramValue));
                    else if (paramValue.isNull())
                        this.params().put(paramField, "null");
                    else
                        this.params().put(paramField, paramValue.asText());
                }
                break;
            case "score":
                this.score(value);
                break;
            default:
                throw new ValidationException("'attributes." + this.name + "." + name + "' is not a recognized field.");
        }
    }
}
 
Example 13
Source File: Validate.java    From product-microgateway with Apache License 2.0 5 votes vote down vote up
/**
 * Replace $ref references with relevant schemas and recreate the swagger definition.
 *
 * @param parent Swagger definition parent Node
 */
private static void generateSchema(JsonNode parent) {
    JsonNode schemaProperty;
    Iterator<Map.Entry<String, JsonNode>> schemaNode;
    if (parent.get(0) != null) {
        schemaNode = parent.get(0).fields();
    } else {
        schemaNode = parent.fields();
    }
    while (schemaNode.hasNext()) {
        Map.Entry<String, JsonNode> entry = schemaNode.next();
        if (entry.getValue().has(Constants.SCHEMA_REFERENCE)) {
            JsonNode refNode = entry.getValue();
            Iterator<Map.Entry<String, JsonNode>> refItems = refNode.fields();
            while (refItems.hasNext()) {
                Map.Entry<String, JsonNode> entryRef = refItems.next();
                if (entryRef.getKey().equals(Constants.SCHEMA_REFERENCE)) {
                    JsonNode schemaObject = extractSchemaObject(entryRef.getValue());
                    if (schemaObject != null) {
                        entry.setValue(schemaObject);
                    }
                }
            }
        }
        schemaProperty = entry.getValue();
        if (JsonNodeType.OBJECT == schemaProperty.getNodeType()) {
            generateSchema(schemaProperty);
        }
        if (JsonNodeType.ARRAY == schemaProperty.getNodeType()) {
            generateArraySchemas(entry);
        }
    }
}
 
Example 14
Source File: DataSource.java    From conciliator with GNU General Public License v3.0 5 votes vote down vote up
public Map<String, SearchResponse> queryMultiple(String queries, SearchQueryFactory searchQueryFactory) {
    log.debug("queries=" + queries);
    try {
        JsonNode root = mapper.readTree(queries);

        Map<String, SearchQuery> queriesMap = new HashMap<>();

        for(Iterator<Map.Entry<String, JsonNode>> iter = root.fields(); iter.hasNext(); ) {
            Map.Entry<String, JsonNode> fieldEntry = iter.next();

            String indexKey = fieldEntry.getKey();
            JsonNode queryStruct = fieldEntry.getValue();

            SearchQuery searchQuery = searchQueryFactory.createSearchQuery(queryStruct);
            queriesMap.put(indexKey, searchQuery);
        }

        Map<String, SearchResponse> resultsMap = search(queriesMap);

        log.debug(String.format("response=%s", new DeferredJSON(resultsMap)));

        return resultsMap;
    } catch (JsonProcessingException jse) {
        log.error("Got an error processing JSON: " + jse.toString());
    } catch (IOException ioe) {
        log.error("Got IO error processing JSON: " + ioe.toString());
    }
    return null;
}
 
Example 15
Source File: Meta.java    From pegasus with Apache License 2.0 5 votes vote down vote up
/**
 * Parses all the attributes back into a Replica Catalog Entry object
 *
 * @param node
 * @return
 */
private ReplicaCatalogEntry createReplicaCatalogEntry(JsonNode node) {
    ReplicaCatalogEntry rce = new ReplicaCatalogEntry();
    for (Iterator<Map.Entry<String, JsonNode>> it = node.fields(); it.hasNext(); ) {
        Map.Entry<String, JsonNode> e = it.next();
        String key = e.getKey();
        String value = e.getValue().asText();
        rce.addAttribute(key, value);
    }
    return rce;
}
 
Example 16
Source File: ParseQuotesTest.java    From td-ameritrade-client with Apache License 2.0 4 votes vote down vote up
@Test
@Ignore
//This isn't needed with the correct Jackson annotations
public void parseMultiTest() throws IOException {
  try (InputStream in = ParseQuotesTest.class.getClassLoader()
      .getResourceAsStream("com/studerw/tda/parse/quotes-resp.json")) {
    List<Quote> quotes = new ArrayList<>();
    ObjectMapper mapper = new ObjectMapper();

    JsonNode root = mapper.readTree(in);
    Iterator<Entry<String, JsonNode>> iter = root.fields();
    while (iter.hasNext()) {
      Entry<String, JsonNode> next = iter.next();
      LOGGER.debug("{} -> {}", next.getKey(), next.getValue().toString());
      JsonNode jsonNode = next.getValue();
      JsonNode assetType = jsonNode.get("assetType");
      String at = assetType.asText();
      LOGGER.debug("AssetType: {}", at);
      AssetType AT = AssetType.valueOf(at);
      switch (AT) {
        case EQUITY:
          EquityQuote eq = mapper.convertValue(jsonNode, EquityQuote.class);
          quotes.add(eq);
          break;
        case MUTUAL_FUND:
          MutualFundQuote mfq = mapper.convertValue(jsonNode, MutualFundQuote.class);
          quotes.add(mfq);
          break;
        case INDEX:
          IndexQuote iq = mapper.convertValue(jsonNode, IndexQuote.class);
          quotes.add(iq);
          break;
        case ETF:
          EtfQuote etfq = mapper.convertValue(jsonNode, EtfQuote.class);
          quotes.add(etfq);
          break;
        case FOREX:
          ForexQuote fq = mapper.convertValue(jsonNode, ForexQuote.class);
          quotes.add(fq);
          break;
        case OPTION:
          OptionQuote oq = mapper.convertValue(jsonNode, OptionQuote.class);
          quotes.add(oq);
          break;
        case FUTURE:
          FutureQuote fuq = mapper.convertValue(jsonNode, FutureQuote.class);
          quotes.add(fuq);
          break;
        case FUTURE_OPTION:
          FutureOptionQuote foq = mapper.convertValue(jsonNode, FutureOptionQuote.class);
          quotes.add(foq);
          break;
      }
    }

    assertThat(quotes).size().isEqualTo(6);
    assertThat(quotes.get(1).getAssetType()).isEqualTo(AssetType.EQUITY);
  }
}
 
Example 17
Source File: NetFlowV9FieldTypeRegistry.java    From graylog-plugin-netflow with Apache License 2.0 4 votes vote down vote up
private static Map<Integer, NetFlowV9FieldType> parseYaml(InputStream inputStream, ObjectMapper yamlMapper) throws IOException {
    final JsonNode node = yamlMapper.readValue(inputStream, JsonNode.class);
    final ImmutableMap.Builder<Integer, NetFlowV9FieldType> mapBuilder = ImmutableMap.builder();
    final Iterator<Map.Entry<String, JsonNode>> fields = node.fields();
    while (fields.hasNext()) {
        final Map.Entry<String, JsonNode> field = fields.next();

        final Integer id;
        try {
            id = Integer.parseInt(field.getKey());
        } catch (NumberFormatException e) {
            LOG.debug("Skipping record with invalid id: {}", field.getKey(), e);
            continue;
        }

        final JsonNode value = field.getValue();

        if (!value.isArray()) {
            LOG.debug("Skipping invalid record: {}", field);
            continue;
        }

        if (value.size() == 1 && ":skip".equals(value.get(0).asText())) {
            LOG.debug("Skipping record: {}", field);
            continue;
        }

        if (value.size() != 2) {
            LOG.debug("Skipping incomplete record: {}", field);
            continue;
        }

        final JsonNode typeNode = value.get(0);
        final NetFlowV9FieldType.ValueType type;
        if (typeNode.isTextual()) {
            type = symbolToValueType(typeNode.asText());
        } else if (typeNode.isInt()) {
            type = intToValueType(typeNode.asInt());
        } else {
            LOG.debug("Skipping invalid record type: {}", field);
            continue;
        }

        final JsonNode nameNode = value.get(1);
        if (!nameNode.isTextual()) {
            LOG.debug("Skipping invalid record type: {}", field);
            continue;
        }

        final String symbol = nameNode.asText();
        final String name = rubySymbolToString(symbol);

        mapBuilder.put(id, NetFlowV9FieldType.create(id, type, name));
    }

    return mapBuilder.build();
}
 
Example 18
Source File: ModulationWebResource.java    From onos with Apache License 2.0 4 votes vote down vote up
public void decode(ObjectNode json) {
    if (json == null || !json.isObject()) {
        throw new IllegalArgumentException(JSON_INVALID);
    }

    JsonNode devicesNode = json.get(DEVICES);
    if (!devicesNode.isObject()) {
        throw new IllegalArgumentException(JSON_INVALID);
    }

    Iterator<Map.Entry<String, JsonNode>> deviceEntries = devicesNode.fields();
    while (deviceEntries.hasNext()) {
        Map.Entry<String, JsonNode> deviceEntryNext = deviceEntries.next();
        String deviceId = deviceEntryNext.getKey();
        ModulationConfig<Object> modulationConfig = getModulationConfig(deviceId);
        JsonNode portsNode = deviceEntryNext.getValue();
        if (!portsNode.isObject()) {
            throw new IllegalArgumentException(JSON_INVALID);
        }

        Iterator<Map.Entry<String, JsonNode>> portEntries = portsNode.fields();
        while (portEntries.hasNext()) {
            Map.Entry<String, JsonNode> portEntryNext = portEntries.next();
            PortNumber portNumber = PortNumber.portNumber(portEntryNext.getKey());
            JsonNode componentsNode = portEntryNext.getValue();
            Iterator<Map.Entry<String, JsonNode>> componentEntries = componentsNode.fields();
            while (componentEntries.hasNext()) {
                Direction direction = null;
                Map.Entry<String, JsonNode> componentEntryNext = componentEntries.next();
                try {
                    direction = Direction.valueOf(componentEntryNext.getKey().toUpperCase());
                } catch (IllegalArgumentException e) {
                    // TODO: Handle other components
                }

                JsonNode bitRateNode = componentEntryNext.getValue();
                if (!bitRateNode.isObject()) {
                    throw new IllegalArgumentException(JSON_INVALID);
                }
                Long targetBitRate = bitRateNode.get(TARGET_BITRATE).asLong();
                if (direction != null) {
                    modulationConfig.setModulationScheme(portNumber, direction, targetBitRate);
                }
            }
        }
    }
}
 
Example 19
Source File: JsonUtil.java    From kite with Apache License 2.0 4 votes vote down vote up
@edu.umd.cs.findbugs.annotations.SuppressWarnings(
    value="BC_UNCONFIRMED_CAST",
    justification="Uses precondition to validate casts")
public static <T> T visit(JsonNode node, JsonTreeVisitor<T> visitor) {
  switch (node.getNodeType()) {
    case OBJECT:
      Preconditions.checkArgument(node instanceof ObjectNode,
          "Expected instance of ObjectNode: " + node);

      // use LinkedHashMap to preserve field order
      Map<String, T> fields = Maps.newLinkedHashMap();

      Iterator<Map.Entry<String, JsonNode>> iter = node.fields();
      while (iter.hasNext()) {
        Map.Entry<String, JsonNode> entry = iter.next();

        visitor.recordLevels.push(entry.getKey());
        fields.put(entry.getKey(), visit(entry.getValue(), visitor));
        visitor.recordLevels.pop();
      }

      return visitor.object((ObjectNode) node, fields);

    case ARRAY:
      Preconditions.checkArgument(node instanceof ArrayNode,
          "Expected instance of ArrayNode: " + node);

      List<T> elements = Lists.newArrayListWithExpectedSize(node.size());

      for (JsonNode element : node) {
        elements.add(visit(element, visitor));
      }

      return visitor.array((ArrayNode) node, elements);

    case BINARY:
      Preconditions.checkArgument(node instanceof BinaryNode,
          "Expected instance of BinaryNode: " + node);
      return visitor.binary((BinaryNode) node);

    case STRING:
      Preconditions.checkArgument(node instanceof TextNode,
          "Expected instance of TextNode: " + node);

      return visitor.text((TextNode) node);

    case NUMBER:
      Preconditions.checkArgument(node instanceof NumericNode,
          "Expected instance of NumericNode: " + node);

      return visitor.number((NumericNode) node);

    case BOOLEAN:
      Preconditions.checkArgument(node instanceof BooleanNode,
          "Expected instance of BooleanNode: " + node);

      return visitor.bool((BooleanNode) node);

    case MISSING:
      Preconditions.checkArgument(node instanceof MissingNode,
          "Expected instance of MissingNode: " + node);

      return visitor.missing((MissingNode) node);

    case NULL:
      Preconditions.checkArgument(node instanceof NullNode,
          "Expected instance of NullNode: " + node);

      return visitor.nullNode((NullNode) node);

    default:
      throw new IllegalArgumentException(
          "Unknown node type: " + node.getNodeType() + ": " + node);
  }
}
 
Example 20
Source File: IstioTypeAnnotator.java    From istio-java-api with Apache License 2.0 4 votes vote down vote up
@Override
public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) {
    JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray("value");
    annotationValue.param("apiVersion");
    annotationValue.param("kind");
    annotationValue.param("metadata");

    final Iterator<Map.Entry<String, JsonNode>> fields = propertiesNode.fields();
    while (fields.hasNext()) {
        final Map.Entry<String, JsonNode> entry = fields.next();
        String key = entry.getKey();
        switch (key) {
            case "kind":
            case "metadata":
            case "apiVersion":
                break;
            case "deprecatedAllowOrigin":
                key = "allowOrigin";
            default:
                annotationValue.param(key);
        }
    }

    final String pkgName = clazz.getPackage().name();
    final int i = pkgName.lastIndexOf('.');
    final String version = pkgName.substring(i + 1);
    if (version.startsWith("v")) {
        final Optional<IstioSpecRegistry.CRDInfo> kind = IstioSpecRegistry.getCRDInfo(clazz.name(), version);
        kind.ifPresent(k -> {
            clazz._implements(IstioSpec.class);
            clazz.annotate(IstioKind.class).param("name", k.getKind()).param("plural", k.getPlural());
            clazz.annotate(IstioApiVersion.class).param("value", k.getAPIVersion());
        });
    }

    clazz.annotate(ToString.class);
    clazz.annotate(EqualsAndHashCode.class);
    JAnnotationUse buildable = clazz.annotate(Buildable.class)
          .param("editableEnabled", false)
          .param("generateBuilderPackage", true)
          .param("builderPackage", BUILDER_PACKAGE);

    buildable.paramArray("inline").annotate(Inline.class)
          .param("type", doneableClass)
          .param("prefix", "Doneable")
          .param("value", "done");

    buildable.paramArray("refs").annotate(BuildableReference.class)
          .param("value", objectMetaClass);

    if (clazz.name().endsWith("Spec")) {
        JAnnotationArrayMember arrayMember = clazz.annotate(VelocityTransformations.class)
              .paramArray("value");
        arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-resource.vm");
        arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-resource-list.vm");
        arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-manifest.vm")
              .param("outputPath", "crd.properties").param("gather", true);
        arrayMember.annotate(VelocityTransformation.class).param("value", "/istio-mappings-provider.vm")
              .param("outputPath", Paths.get("me", "snowdrop", "istio", "api", "model",
                    "IstioResourceMappingsProvider.java").toString())
              .param("gather", true);
    }
}