From cc92ef953a71db2cb27f11479244a176b46401da Mon Sep 17 00:00:00 2001 From: Speiger Date: Wed, 7 Dec 2022 03:23:19 +0100 Subject: [PATCH] Added Dependency Checks into the Module System. Why a Dependency Check system was added? --- ModulSettings.json | 52 +++++++++---------- .../builder/PrimitiveCollectionsBuilder.java | 45 +++++++++++----- .../src/builder/modules/AsyncModule.java | 4 ++ .../src/builder/modules/BaseModule.java | 16 +++++- .../src/builder/modules/CollectionModule.java | 2 + .../src/builder/modules/FunctionModule.java | 2 + .../src/builder/modules/JavaModule.java | 2 + .../src/builder/modules/ListModule.java | 10 +++- .../src/builder/modules/MapModule.java | 7 +++ .../src/builder/modules/PairModule.java | 1 + .../src/builder/modules/PrioQueueModule.java | 5 +- .../src/builder/modules/SetModule.java | 13 +++-- 12 files changed, 107 insertions(+), 52 deletions(-) diff --git a/ModulSettings.json b/ModulSettings.json index 634f21d..ef31735 100644 --- a/ModulSettings.json +++ b/ModulSettings.json @@ -4,10 +4,10 @@ "Collection": true, "Function": true, "List": true, - "Map": false, + "Map": true, "Pair": true, "PriorityQueue": true, - "Set": false, + "Set": true, "Boolean": { "Enabled": true, "Base": { @@ -367,15 +367,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, @@ -638,15 +638,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, @@ -909,15 +909,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, @@ -1180,15 +1180,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, @@ -1451,15 +1451,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, @@ -1722,15 +1722,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, @@ -1993,15 +1993,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, @@ -2264,15 +2264,15 @@ }, "Set": { "Enabled": true, - "LinkedHashSet": false, - "LinkedCustomHashSet": false, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, "OrderedSet": true, "ArraySet": true, "AVLTreeSet": true, "ImmutableSet": true, "CustomHashSet": true, "Sets": true, - "SortedSet": false, + "SortedSet": true, "HashSet": true, "RBTreeSet": true }, diff --git a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java index e495c6f..cd50dc5 100644 --- a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java +++ b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java @@ -122,28 +122,45 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor } } + public List createModules() + { + List modules = new ArrayList<>(); + modules.add(JavaModule.INSTANCE); + modules.add(FunctionModule.INSTANCE); + modules.add(CollectionModule.INSTANCE); + modules.add(PrioQueueModule.INSTANCE); + modules.add(ListModule.INSTANCE); + modules.add(SetModule.INSTANCE); + modules.add(MapModule.INSTANCE); + modules.add(PairModule.INSTANCE); + modules.add(AsyncModule.INSTANCE); + return modules; + } + + @Override protected void init() { prepPackages(); //Init Modules here - addModule(new JavaModule()); - addModule(new FunctionModule()); - addModule(new CollectionModule()); - addModule(new PrioQueueModule()); - addModule(new ListModule()); - addModule(new SetModule()); - addModule(new MapModule()); - addModule(new PairModule()); - addModule(new AsyncModule()); + addModules(createModules()); finishPackages(); } - public void addModule(BaseModule module) + public void addModules(List modules) { - module.setManager(manager); - biPackages.forEach(module::init); - module.cleanup(); + if((flags & LOAD) != 0) + { + for(int i = 0,m=modules.size();i getModuleKeys(ClassType keyType, ClassType valueType) - { + public Set getModuleKeys(ClassType keyType, ClassType valueType) { return new HashSet<>(Arrays.asList("Lists", "ArrayList", "LinkedList", "ImmutableList", "CopyOnWriteList")); } + @Override + protected boolean areDependenciesLoaded() { + return isDependencyLoaded(CollectionModule.INSTANCE); + } + @Override protected void loadRemappers() { diff --git a/src/builder/java/speiger/src/builder/modules/MapModule.java b/src/builder/java/speiger/src/builder/modules/MapModule.java index 25d396e..a5234b0 100644 --- a/src/builder/java/speiger/src/builder/modules/MapModule.java +++ b/src/builder/java/speiger/src/builder/modules/MapModule.java @@ -9,6 +9,8 @@ import speiger.src.builder.ClassType; @SuppressWarnings("javadoc") public class MapModule extends BaseModule { + public static final BaseModule INSTANCE = new MapModule(); + @Override public String getModuleName() { return "Map"; } @Override @@ -32,6 +34,11 @@ public class MapModule extends BaseModule return sets; } + @Override + protected boolean areDependenciesLoaded() { + return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); + } + @Override protected void loadFlags() { diff --git a/src/builder/java/speiger/src/builder/modules/PairModule.java b/src/builder/java/speiger/src/builder/modules/PairModule.java index 6af7553..513ef17 100644 --- a/src/builder/java/speiger/src/builder/modules/PairModule.java +++ b/src/builder/java/speiger/src/builder/modules/PairModule.java @@ -3,6 +3,7 @@ package speiger.src.builder.modules; @SuppressWarnings("javadoc") public class PairModule extends BaseModule { + public static final BaseModule INSTANCE = new PairModule(); @Override public String getModuleName() { return "Pair"; } @Override diff --git a/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java index 0b2d132..2feba22 100644 --- a/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java +++ b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java @@ -5,6 +5,8 @@ import speiger.src.builder.ClassType; @SuppressWarnings("javadoc") public class PrioQueueModule extends BaseModule { + public static final BaseModule INSTANCE = new PrioQueueModule(); + @Override public String getModuleName() { return "PriorityQueue"; } @Override @@ -13,7 +15,8 @@ public class PrioQueueModule extends BaseModule protected void loadFlags() {} @Override protected void loadFunctions() {} - + @Override + protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } @Override protected void loadBlockades() { diff --git a/src/builder/java/speiger/src/builder/modules/SetModule.java b/src/builder/java/speiger/src/builder/modules/SetModule.java index 9d880ae..469a5d8 100644 --- a/src/builder/java/speiger/src/builder/modules/SetModule.java +++ b/src/builder/java/speiger/src/builder/modules/SetModule.java @@ -9,20 +9,19 @@ import speiger.src.builder.ClassType; @SuppressWarnings("javadoc") public class SetModule extends BaseModule { + public static final BaseModule INSTANCE = new SetModule(); + @Override public String getModuleName() { return "Set"; } @Override protected void loadVariables() {} @Override - public boolean isModuleValid(ClassType keyType, ClassType valueType) - { - return keyType != ClassType.BOOLEAN; - } - + public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; } @Override - public Set getModuleKeys(ClassType keyType, ClassType valueType) - { + protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) { Set sets = new HashSet<>(); sets.add("Sets"); sets.addAll(Arrays.asList("OrderedSet", "SortedSet"));