+ if (resolvedID.startsWith("class:"))
+ {
+ String className = resolvedID.substring(6);
+ tryLoadComponentClass(className);
+ ComponentSupplier componentSupplier = componentSuppliers.get(className);
+ if (componentSupplier != null)
+ return componentSupplier.create(model, params, name);
+ throw new IllegalArgumentException("Component supplier not found for ID " + id + " (resolved: " + resolvedID + ")");
+ } else
+ // we know id has to start with "file:" here
+ // because standardComponentIDs only contains strings starting with "class:" or "file:"
+ if (params != null && !JsonNull.INSTANCE.equals(params))
+ throw new IllegalArgumentException("Can't give params to a component deserialized from a JSON file");
+ try
+ {
+ String filename = resolvedID.substring(5);
+ JsonObject jsonContents = JsonHandler.readJson(filename, JsonObject.class);
+ SerializablePojo jsonContentsAsSerializablePojo = JsonHandler.parser.fromJson(jsonContents, SerializablePojo.class);
+ if (jsonContentsAsSerializablePojo.version == null)
+ return LegacySubmodelComponentSerializer.deserialize(model,
+ JsonHandler.parser.fromJson(jsonContents, LegacySubmodelComponentParams.class), name, id, null);
+ return SubmodelComponentSerializer.deserialize(model,
+ JsonHandler.parser.fromJson(jsonContents, SubmodelComponentParams.class), name, id, null);
+ }
+ catch (IOException e)
+ {
+ throw new UncheckedIOException(e);
+ }