Serializing now serializes everything; among many other things:
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / serializing / IdentifierGetter.java
diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifierGetter.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/serializing/IdentifierGetter.java
new file mode 100644 (file)
index 0000000..f1bb5f0
--- /dev/null
@@ -0,0 +1,36 @@
+package net.mograsim.logic.model.serializing;
+
+import java.util.function.Function;
+
+import net.mograsim.logic.model.model.components.GUIComponent;
+import net.mograsim.logic.model.snippets.HighLevelStateHandler;
+import net.mograsim.logic.model.snippets.Renderer;
+import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic.AtomicHighLevelStateHandler;
+import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.subcomponent.SubcomponentHighLevelStateHandler;
+
+//TODO better name
+public class IdentifierGetter
+{
+       // TODO save IDs for everything than can be deserialized / serialized (=every JSONSerializable?)
+       public Function<GUIComponent, String> componentIDs;
+       public Function<Renderer, String> symbolRendererIDs;
+       public Function<Renderer, String> outlineRendererIDs;
+       public Function<HighLevelStateHandler, String> highLevelStateHandlerIDs;
+       public Function<SubcomponentHighLevelStateHandler, String> subcomponentHighLevelStateHandlerIDs;
+       public Function<AtomicHighLevelStateHandler, String> atomicHighLevelStateHandlerIDs;
+
+       /**
+        * Creates a new IdentifierGetter using "class:" concatenated with a component's / snippet's complete (canonical) class name as the
+        * default for all ID getter functions.
+        */
+       public IdentifierGetter()
+       {
+               Function<Object, String> defaultSnippetIDGetter = c -> "class:" + c.getClass().getCanonicalName();
+               this.componentIDs = defaultSnippetIDGetter::apply;
+               this.symbolRendererIDs = defaultSnippetIDGetter::apply;
+               this.outlineRendererIDs = defaultSnippetIDGetter::apply;
+               this.highLevelStateHandlerIDs = defaultSnippetIDGetter::apply;
+               this.subcomponentHighLevelStateHandlerIDs = defaultSnippetIDGetter::apply;
+               this.atomicHighLevelStateHandlerIDs = defaultSnippetIDGetter::apply;
+       }
+}
\ No newline at end of file