X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fserializing%2FIndirectModelComponentCreator.java;h=13205b286f3c1e590256cf551555eb674711261f;hb=3048bf7b4b4494a5a904c1a678bad2dab6d711f1;hp=926e48b5b9dfd34936953cb3e26c6a1a2ccc4c4f;hpb=9d052008d599bfc1482cc7802cefc53e76ce9537;p=Mograsim.git diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java index 926e48b5..13205b28 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IndirectModelComponentCreator.java @@ -95,7 +95,7 @@ public class IndirectModelComponentCreator if (id == null) throw new NullPointerException("Component ID is null"); if (componentCache.containsKey(id)) - return loadComponentFromJsonObject(model, id, name, componentCache.get(id)); + return loadComponentFromJsonObject(model, id, name, componentCache.get(id), false); String resolvedID = resolveID(id); if (resolvedID == null) throw new IllegalArgumentException("Unknown standard ID or illegal resolved ID: " + id); @@ -113,7 +113,7 @@ public class IndirectModelComponentCreator { throw new UncheckedIOException("Error loading JSON file", e); } - return loadComponentFromJsonObject(model, id, name, jsonContents); + return loadComponentFromJsonObject(model, id, name, jsonContents, false); } ResourceLoader loader; String resTypeID; @@ -149,7 +149,7 @@ public class IndirectModelComponentCreator { throw new UncheckedIOException("Error loading JSON resource", e); } - return loadComponentFromJsonObject(model, id, name, jsonContents); + return loadComponentFromJsonObject(model, id, name, jsonContents, true); } else if (resTypeID.equals("class")) { ComponentSupplier componentSupplier = componentSuppliers.get(resID); @@ -184,9 +184,10 @@ public class IndirectModelComponentCreator } private static SubmodelComponent loadComponentFromJsonObject(LogicModelModifiable model, String id, String name, - SubmodelComponentParams jsonContents) + SubmodelComponentParams jsonContents, boolean cache) { - componentCache.putIfAbsent(id, jsonContents); + if (cache) + componentCache.putIfAbsent(id, jsonContents); return SubmodelComponentSerializer.deserialize(model, jsonContents, name, id, null); }