Serializing now serializes everything; among many other things:
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / serializing / IdentifierGetter.java
1 package net.mograsim.logic.model.serializing;
2
3 import java.util.function.Function;
4
5 import net.mograsim.logic.model.model.components.GUIComponent;
6 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
7 import net.mograsim.logic.model.snippets.Renderer;
8 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic.AtomicHighLevelStateHandler;
9 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.subcomponent.SubcomponentHighLevelStateHandler;
10
11 //TODO better name
12 public class IdentifierGetter
13 {
14         // TODO save IDs for everything than can be deserialized / serialized (=every JSONSerializable?)
15         public Function<GUIComponent, String> componentIDs;
16         public Function<Renderer, String> symbolRendererIDs;
17         public Function<Renderer, String> outlineRendererIDs;
18         public Function<HighLevelStateHandler, String> highLevelStateHandlerIDs;
19         public Function<SubcomponentHighLevelStateHandler, String> subcomponentHighLevelStateHandlerIDs;
20         public Function<AtomicHighLevelStateHandler, String> atomicHighLevelStateHandlerIDs;
21
22         /**
23          * Creates a new IdentifierGetter using "class:" concatenated with a component's / snippet's complete (canonical) class name as the
24          * default for all ID getter functions.
25          */
26         public IdentifierGetter()
27         {
28                 Function<Object, String> defaultSnippetIDGetter = c -> "class:" + c.getClass().getCanonicalName();
29                 this.componentIDs = defaultSnippetIDGetter::apply;
30                 this.symbolRendererIDs = defaultSnippetIDGetter::apply;
31                 this.outlineRendererIDs = defaultSnippetIDGetter::apply;
32                 this.highLevelStateHandlerIDs = defaultSnippetIDGetter::apply;
33                 this.subcomponentHighLevelStateHandlerIDs = defaultSnippetIDGetter::apply;
34                 this.atomicHighLevelStateHandlerIDs = defaultSnippetIDGetter::apply;
35         }
36 }