Improving Dependency Checks to be more recursive.

This commit is contained in:
Speiger 2022-12-07 03:30:29 +01:00
parent cc92ef953a
commit 1b1ec4b87a
8 changed files with 13 additions and 15 deletions

View File

@ -30,7 +30,7 @@ public class SettingsManager
if(!isEnabled(result, "Enabled")) return false; if(!isEnabled(result, "Enabled")) return false;
} }
result = getObject(result, base.getModuleName(), 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) public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType, String entry)
@ -44,7 +44,7 @@ public class SettingsManager
if(!isEnabled(result, "Enabled")) return false; if(!isEnabled(result, "Enabled")) return false;
} }
result = getObject(result, base.getModuleName(), 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) { public void addModule(BaseModule module) {

View File

@ -16,7 +16,7 @@ public class AsyncModule extends BaseModule
@Override @Override
protected void loadFunctions() {} protected void loadFunctions() {}
@Override @Override
protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
@Override @Override
protected void loadBlockades() { protected void loadBlockades() {
if(!isModuleEnabled()) { if(!isModuleEnabled()) {

View File

@ -60,11 +60,11 @@ public abstract class BaseModule
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; } public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
protected boolean isModuleEnabled() { 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) { 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) { 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))); 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; return true;
} }

View File

@ -13,7 +13,8 @@ public class CollectionModule extends BaseModule
protected void loadVariables() {} protected void loadVariables() {}
@Override @Override
protected void loadFlags() {} protected void loadFlags() {}
@Override
public boolean areDependenciesLoaded(){ return isDependencyLoaded(JavaModule.INSTANCE); }
@Override @Override
protected void loadBlockades() protected void loadBlockades()
{ {

View File

@ -45,7 +45,7 @@ public class ListModule extends BaseModule
} }
@Override @Override
protected boolean areDependenciesLoaded() { public boolean areDependenciesLoaded() {
return isDependencyLoaded(CollectionModule.INSTANCE); return isDependencyLoaded(CollectionModule.INSTANCE);
} }

View File

@ -19,6 +19,8 @@ public class MapModule extends BaseModule
protected void loadVariables() {} protected void loadVariables() {}
@Override @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 boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
@Override @Override
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) public Set<String> getModuleKeys(ClassType keyType, ClassType valueType)
@ -34,11 +36,6 @@ public class MapModule extends BaseModule
return sets; return sets;
} }
@Override
protected boolean areDependenciesLoaded() {
return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false);
}
@Override @Override
protected void loadFlags() protected void loadFlags()
{ {

View File

@ -16,7 +16,7 @@ public class PrioQueueModule extends BaseModule
@Override @Override
protected void loadFunctions() {} protected void loadFunctions() {}
@Override @Override
protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
@Override @Override
protected void loadBlockades() protected void loadBlockades()
{ {

View File

@ -19,7 +19,7 @@ public class SetModule extends BaseModule
@Override @Override
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; } public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
@Override @Override
protected boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
@Override @Override
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
Set<String> sets = new HashSet<>(); Set<String> sets = new HashSet<>();