The final restructured version for automatic build using maven tycho
[Mograsim.git] / plugins / net.mograsim.logic.model / src / net / mograsim / logic / model / snippets / highlevelstatehandlers / standard / StandardHighLevelStateHandlerSnippetSuppliers.java
1 package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.util.Map;
6
7 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
8 import net.mograsim.logic.model.snippets.CodeSnippetSupplier;
9 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic.AtomicHighLevelStateHandler;
10 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.subcomponent.SubcomponentHighLevelStateHandler;
11 import net.mograsim.logic.model.util.JsonHandler;
12
13 public class StandardHighLevelStateHandlerSnippetSuppliers
14 {
15         public static final CodeSnippetSupplier<SubmodelComponent, AtomicHighLevelStateHandler> atomicHandlerSupplier;
16         public static final CodeSnippetSupplier<SubmodelComponent, SubcomponentHighLevelStateHandler> subcomponentHandlerSupplier;
17
18         static
19         {
20                 atomicHandlerSupplier = new CodeSnippetSupplier<>(null);
21                 subcomponentHandlerSupplier = new CodeSnippetSupplier<>(null);
22         }
23
24         static
25         {
26                 try (InputStream s = StandardHighLevelStateHandlerSnippetSuppliers.class.getResourceAsStream("standardSnippetIDMapping.json"))
27                 {
28                         if (s == null)
29                                 throw new IOException("Resource not found");
30                         SnippetIDClassNames tmp = JsonHandler.readJson(s, SnippetIDClassNames.class);
31                         tmp.standardSubcomponentHandlerSuppliers.forEach(subcomponentHandlerSupplier::addStandardSnippetID);
32                         tmp.standardAtomicHandlerSuppliers.forEach(atomicHandlerSupplier::addStandardSnippetID);
33                 }
34                 catch (Exception e)
35                 {
36                         System.err.println("Failed to initialize standard snippet ID mapping: ");
37                         e.printStackTrace();
38                 }
39         }
40
41         private static class SnippetIDClassNames
42         {
43                 public Map<String, String> standardSubcomponentHandlerSuppliers;
44                 public Map<String, String> standardAtomicHandlerSuppliers;
45         }
46
47         private StandardHighLevelStateHandlerSnippetSuppliers()
48         {
49                 throw new UnsupportedOperationException();
50         }
51 }