Source:
private static JSONObject addMetadata(final JSONObject schema, final EventType eventType) { normalizeSchema(schema); final JSONObject metadata = new JSONObject(); final JSONObject metadataProperties = new JSONObject(); final JSONObject uuid = new JSONObject() .put("type", "string") .put("pattern", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"); final JSONObject arrayOfUUIDs = new JSONObject() .put("type", "array") .put("items", uuid); final JSONObject eventTypeString = new JSONObject() .put("type", "string") .put("enum", Arrays.asList(new String[]{eventType.getName()})); final JSONObject string = new JSONObject().put("type", "string"); final JSONObject dateTime = new JSONObject() .put("type", "string"); metadataProperties.put("eid", uuid); metadataProperties.put("event_type", eventTypeString); metadataProperties.put("occurred_at", dateTime); metadataProperties.put("parent_eids", arrayOfUUIDs); metadataProperties.put("flow_id", string); metadataProperties.put("partition", string); metadataProperties.put("partition_compaction_key", string); final ArrayList<String> requiredFields = newArrayList("eid", "occurred_at"); if (eventType.getCleanupPolicy() == CleanupPolicy.COMPACT) { final JSONObject compactionKey = new JSONObject() .put("type", "string") .put("minLength", 1); metadataProperties.put("partition_compaction_key", compactionKey); requiredFields.add("partition_compaction_key"); } metadata.put("type", "object"); metadata.put("properties", metadataProperties); metadata.put("required", requiredFields); metadata.put("additionalProperties", false); schema.getJSONObject("properties").put("metadata", metadata); addToRequired(schema, new String[]{"metadata"}); return schema; }

Target:
private static JSONObject addMetadata(final JSONObject schema, final EventType eventType) { normalizeSchema(schema); final JSONObject metadata = new JSONObject(); final JSONObject metadataProperties = new JSONObject(); final JSONObject uuid = new JSONObject() .put("type", "string") .put("pattern", "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"); final JSONObject arrayOfUUIDs = new JSONObject() .put("type", "array") .put("items", uuid); final JSONObject eventTypeString = new JSONObject() .put("type", "string") .put("enum", Arrays.asList(new String[]{eventType.getName()})); final JSONObject string = new JSONObject().put("type", "string"); final JSONObject dateTime = new JSONObject() .put("type", "string"); metadataProperties.put("eid", uuid); metadataProperties.put("event_type", eventTypeString); metadataProperties.put("occurred_at", dateTime); metadataProperties.put("parent_eids", arrayOfUUIDs); metadataProperties.put("flow_id", string); metadataProperties.put("partition", string); final ArrayList<String> requiredFields = newArrayList("eid", "occurred_at"); if (eventType.getCleanupPolicy() == CleanupPolicy.COMPACT) { final JSONObject compactionKey = new JSONObject() .put("type", "string") .put("minLength", 1); metadataProperties.put("partition_compaction_key", compactionKey); requiredFields.add("partition_compaction_key"); } metadata.put("type", "object"); metadata.put("properties", metadataProperties); metadata.put("required", requiredFields); metadata.put("additionalProperties", false); schema.getJSONObject("properties").put("metadata", metadata); addToRequired(schema, new String[]{"metadata"}); return schema; }