From 1b1ec4b87a7a9c874eac8ff183726a9a7dff3ae4 Mon Sep 17 00:00:00 2001 From: Speiger Date: Wed, 7 Dec 2022 03:30:29 +0100 Subject: [PATCH] Improving Dependency Checks to be more recursive. --- src/builder/java/speiger/src/builder/SettingsManager.java | 4 ++-- .../java/speiger/src/builder/modules/AsyncModule.java | 2 +- .../java/speiger/src/builder/modules/BaseModule.java | 6 +++--- .../java/speiger/src/builder/modules/CollectionModule.java | 3 ++- .../java/speiger/src/builder/modules/ListModule.java | 2 +- .../java/speiger/src/builder/modules/MapModule.java | 7 ++----- .../java/speiger/src/builder/modules/PrioQueueModule.java | 2 +- .../java/speiger/src/builder/modules/SetModule.java | 2 +- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/builder/java/speiger/src/builder/SettingsManager.java b/src/builder/java/speiger/src/builder/SettingsManager.java index 59cbe6a8..1fcfd3c1 100644 --- a/src/builder/java/speiger/src/builder/SettingsManager.java +++ b/src/builder/java/speiger/src/builder/SettingsManager.java @@ -30,7 +30,7 @@ public class SettingsManager if(!isEnabled(result, "Enabled")) return false; } result = getObject(result, base.getModuleName(), false); - return result.size() <= 0 || isEnabled(result, "Enabled"); + return (result.size() <= 0 || isEnabled(result, "Enabled")) && base.areDependenciesLoaded(); } public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType, String entry) @@ -44,7 +44,7 @@ public class SettingsManager if(!isEnabled(result, "Enabled")) return false; } result = getObject(result, base.getModuleName(), false); - return result.size() <= 0 || (isEnabled(result, "Enabled") && isEnabled(result, entry)); + return (result.size() <= 0 || (isEnabled(result, "Enabled") && isEnabled(result, entry))) && base.areDependenciesLoaded(); } public void addModule(BaseModule module) { diff --git a/src/builder/java/speiger/src/builder/modules/AsyncModule.java b/src/builder/java/speiger/src/builder/modules/AsyncModule.java index 6feee4d3..fd257751 100644 --- a/src/builder/java/speiger/src/builder/modules/AsyncModule.java +++ b/src/builder/java/speiger/src/builder/modules/AsyncModule.java @@ -16,7 +16,7 @@ public class AsyncModule extends BaseModule @Override protected void loadFunctions() {} @Override - protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } + public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } @Override protected void loadBlockades() { if(!isModuleEnabled()) { diff --git a/src/builder/java/speiger/src/builder/modules/BaseModule.java b/src/builder/java/speiger/src/builder/modules/BaseModule.java index a51b95c0..a3ffc0d8 100644 --- a/src/builder/java/speiger/src/builder/modules/BaseModule.java +++ b/src/builder/java/speiger/src/builder/modules/BaseModule.java @@ -60,11 +60,11 @@ public abstract class BaseModule public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; } protected boolean isModuleEnabled() { - return manager == null || (manager.isModuleEnabled(this, keyType, valueType) && areDependenciesLoaded()); + return manager == null || manager.isModuleEnabled(this, keyType, valueType); } protected boolean isModuleEnabled(String name) { - return manager == null || (manager.isModuleEnabled(this, keyType, valueType, name) && areDependenciesLoaded()); + return manager == null || manager.isModuleEnabled(this, keyType, valueType, name); } protected boolean isDependencyLoaded(BaseModule module) { @@ -75,7 +75,7 @@ public abstract class BaseModule return manager == null || (module.isBiModule() ? manager.isModuleEnabled(module, keyType, valueType) : (key ? manager.isModuleEnabled(module, keyType, keyType) : manager.isModuleEnabled(module, valueType, valueType))); } - protected boolean areDependenciesLoaded() { + public boolean areDependenciesLoaded() { return true; } diff --git a/src/builder/java/speiger/src/builder/modules/CollectionModule.java b/src/builder/java/speiger/src/builder/modules/CollectionModule.java index 47c43172..3dcfb8ac 100644 --- a/src/builder/java/speiger/src/builder/modules/CollectionModule.java +++ b/src/builder/java/speiger/src/builder/modules/CollectionModule.java @@ -13,7 +13,8 @@ public class CollectionModule extends BaseModule protected void loadVariables() {} @Override protected void loadFlags() {} - + @Override + public boolean areDependenciesLoaded(){ return isDependencyLoaded(JavaModule.INSTANCE); } @Override protected void loadBlockades() { diff --git a/src/builder/java/speiger/src/builder/modules/ListModule.java b/src/builder/java/speiger/src/builder/modules/ListModule.java index 6f42ec11..32e15fce 100644 --- a/src/builder/java/speiger/src/builder/modules/ListModule.java +++ b/src/builder/java/speiger/src/builder/modules/ListModule.java @@ -45,7 +45,7 @@ public class ListModule extends BaseModule } @Override - protected boolean areDependenciesLoaded() { + public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } diff --git a/src/builder/java/speiger/src/builder/modules/MapModule.java b/src/builder/java/speiger/src/builder/modules/MapModule.java index a5234b03..bccb8189 100644 --- a/src/builder/java/speiger/src/builder/modules/MapModule.java +++ b/src/builder/java/speiger/src/builder/modules/MapModule.java @@ -19,6 +19,8 @@ public class MapModule extends BaseModule protected void loadVariables() {} @Override public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; } + @Override + public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); } @Override public Set getModuleKeys(ClassType keyType, ClassType valueType) @@ -34,11 +36,6 @@ 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/PrioQueueModule.java b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java index 2feba225..2179af92 100644 --- a/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java +++ b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java @@ -16,7 +16,7 @@ public class PrioQueueModule extends BaseModule @Override protected void loadFunctions() {} @Override - protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } + public 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 469a5d83..ba846900 100644 --- a/src/builder/java/speiger/src/builder/modules/SetModule.java +++ b/src/builder/java/speiger/src/builder/modules/SetModule.java @@ -19,7 +19,7 @@ public class SetModule extends BaseModule @Override public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; } @Override - protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } + public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } @Override public Set getModuleKeys(ClassType keyType, ClassType valueType) { Set sets = new HashSet<>();