public static void registerObjectsExportedDefinitions( @NotNull VirtualFile key, @NotNull final JsonSchemaExportedDefinitions definitionsObject, @NotNull final JsonSchemaObject object) { String id = object.getId(); if (!StringUtil.isEmptyOrSpaces(id)) { id = id.endsWith("#") ? id.substring(0, id.length() - 1) : id; final BiFunction<String, Map<String, JsonSchemaObject>, Map<String, JsonSchemaObject>> convertor = (s, map) -> { final Map<String, JsonSchemaObject> converted = new HashMap<>(); for (Map.Entry<String, JsonSchemaObject> entry : map.entrySet()) { String key1 = entry.getKey(); key1 = key1.startsWith("/") ? key1.substring(1) : key1; converted.put(s + key1, entry.getValue()); } return converted; }; final HashMap<String, JsonSchemaObject> map = new HashMap<>(); map.put("", object); final Map<String, JsonSchemaObject> definitions = object.getDefinitions(); if (definitions != null && !definitions.isEmpty()) { map.putAll(convertor.apply("#/definitions/", definitions)); } final Map<String, JsonSchemaObject> properties = object.getProperties(); if (properties != null && !properties.isEmpty()) { map.putAll(convertor.apply("#/properties/", properties)); } definitionsObject.register(key, id, map); } }
@Override public JsonSchemaObject read(JsonReader in) throws IOException { in.beginObject(); final JsonSchemaObject object = new JsonSchemaObject(); while (in.peek() == JsonToken.NAME) { final String name = in.nextName(); readSomeProperty(in, name, object); } in.endObject(); myAllObjects.add(object); if (object.getId() != null) { myIds.put(object.getId(), object); } return object; }