From b29874189cb632fc9a34761a1366c4ff02553b4f Mon Sep 17 00:00:00 2001 From: Speiger Date: Sun, 4 Dec 2022 07:56:04 +0100 Subject: [PATCH] Finishing Framework and making Async Module Optional. --- ModulSettings.json | 180 ++++++++---------- .../builder/PrimitiveCollectionsBuilder.java | 2 +- .../speiger/src/builder/SettingsManager.java | 31 ++- .../src/builder/modules/AsyncModule.java | 15 +- .../src/builder/modules/BaseModule.java | 14 +- .../src/builder/modules/CollectionModule.java | 5 +- .../src/builder/modules/FunctionModule.java | 5 +- .../src/builder/modules/JavaModule.java | 4 +- .../src/builder/modules/ListModule.java | 10 +- .../src/builder/modules/MapModule.java | 5 +- .../src/builder/modules/PairModule.java | 2 + .../src/builder/modules/PrioQueueModule.java | 5 +- .../src/builder/modules/SetModule.java | 5 +- .../templates/collections/Iterable.template | 4 + .../templates/utils/AsyncBuilder.template | 28 ++- 15 files changed, 188 insertions(+), 127 deletions(-) diff --git a/ModulSettings.json b/ModulSettings.json index 9534e91c..1a48122c 100644 --- a/ModulSettings.json +++ b/ModulSettings.json @@ -9,108 +9,10 @@ "PriorityQueue": true, "Set": true, "Boolean": { + "enabled": true, "Base": { "enabled": true }, - "Boolean": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Byte": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Short": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Character": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Integer": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Long": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Float": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Double": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, - "Object": { - "Function": { - "enabled": true - }, - "Map": { - "enabled": true - }, - "Pair": { - "enabled": true - } - }, "Collection": { "enabled": true }, @@ -128,10 +30,12 @@ } }, "Byte": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -143,6 +47,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -154,6 +59,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -165,6 +71,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -176,6 +83,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -187,6 +95,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -198,6 +107,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -209,6 +119,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -220,6 +131,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, @@ -247,10 +159,12 @@ } }, "Short": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -262,6 +176,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -273,6 +188,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -284,6 +200,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -295,6 +212,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -306,6 +224,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -317,6 +236,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -328,6 +248,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -339,6 +260,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, @@ -366,10 +288,12 @@ } }, "Character": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -381,6 +305,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -392,6 +317,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -403,6 +329,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -414,6 +341,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -425,6 +353,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -436,6 +365,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -447,6 +377,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -458,6 +389,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, @@ -485,10 +417,12 @@ } }, "Integer": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -500,6 +434,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -511,6 +446,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -522,6 +458,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -533,6 +470,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -544,6 +482,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -555,6 +494,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -566,6 +506,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -577,6 +518,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, @@ -604,10 +546,12 @@ } }, "Long": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -619,6 +563,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -630,6 +575,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -641,6 +587,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -652,6 +599,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -663,6 +611,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -674,6 +623,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -685,6 +635,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -696,6 +647,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, @@ -723,10 +675,12 @@ } }, "Float": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -738,6 +692,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -749,6 +704,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -760,6 +716,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -771,6 +728,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -782,6 +740,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -793,6 +752,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -804,6 +764,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -815,6 +776,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, @@ -842,10 +804,12 @@ } }, "Double": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -857,6 +821,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -868,6 +833,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -879,6 +845,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -890,6 +857,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -901,6 +869,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -912,6 +881,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -923,6 +893,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -934,6 +905,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, @@ -961,10 +933,12 @@ } }, "Object": { + "enabled": true, "Base": { "enabled": true }, "Boolean": { + "enabled": true, "Function": { "enabled": true }, @@ -976,6 +950,7 @@ } }, "Byte": { + "enabled": true, "Function": { "enabled": true }, @@ -987,6 +962,7 @@ } }, "Short": { + "enabled": true, "Function": { "enabled": true }, @@ -998,6 +974,7 @@ } }, "Character": { + "enabled": true, "Function": { "enabled": true }, @@ -1009,6 +986,7 @@ } }, "Integer": { + "enabled": true, "Function": { "enabled": true }, @@ -1020,6 +998,7 @@ } }, "Long": { + "enabled": true, "Function": { "enabled": true }, @@ -1031,6 +1010,7 @@ } }, "Float": { + "enabled": true, "Function": { "enabled": true }, @@ -1042,6 +1022,7 @@ } }, "Double": { + "enabled": true, "Function": { "enabled": true }, @@ -1053,6 +1034,7 @@ } }, "Object": { + "enabled": true, "Function": { "enabled": true }, diff --git a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java index dc99a0ce..ddb7a073 100644 --- a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java +++ b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java @@ -239,7 +239,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor boolean tests = flags.contains("tests"); boolean forceTests = flags.contains("force-tests"); boolean load = flags.contains("load"); - boolean save = !flags.contains("save"); + boolean save = flags.contains("save"); int flag = (load ? LOAD : 0) | (save ? SAVE : 0); // new PrimitiveCollectionsBuilder(silent).test(); new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force); diff --git a/src/builder/java/speiger/src/builder/SettingsManager.java b/src/builder/java/speiger/src/builder/SettingsManager.java index 438ac210..d97e63d8 100644 --- a/src/builder/java/speiger/src/builder/SettingsManager.java +++ b/src/builder/java/speiger/src/builder/SettingsManager.java @@ -20,13 +20,30 @@ public class SettingsManager JsonObject data = new JsonObject(); Set moduleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType) { + if(!loaded) return true; + if(!isEnabled(data, base.getModuleName())) return false; + JsonObject result = getObject(data, keyType.getClassPath(), false); + if(!isEnabled(result, "enabled")) return false; + if(base.isBiModule()) { + result = getObject(result, valueType.getClassPath(), false); + if(!isEnabled(result, "enabled")) return false; + } + result = getObject(result, base.getModuleName(), false); + return result.size() <= 0 || isEnabled(result, "enabled"); + } + public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType, String entry) { if(!loaded) return true; if(!isEnabled(data, base.getModuleName())) return false; - JsonObject result = getObject(data, keyType.getClassPath()); - if(base.isBiModule()) result = getObject(result, valueType.getClassPath()); - result = getObject(result, base.getModuleName()); + JsonObject result = getObject(data, keyType.getClassPath(), false); + if(!isEnabled(result, "enabled")) return false; + if(base.isBiModule()) { + result = getObject(result, valueType.getClassPath(), false); + if(!isEnabled(result, "enabled")) return false; + } + result = getObject(result, base.getModuleName(), false); return result.size() <= 0 || (isEnabled(result, "enabled") && isEnabled(result, entry)); } @@ -37,6 +54,7 @@ public class SettingsManager data.addProperty(moduleName, true); if(module.isBiModule()) { for(ClassType keyType : ModulePackage.TYPE) { + if(keyType == ClassType.BOOLEAN) continue; for(ClassType valueType : ModulePackage.TYPE) { JsonObject obj = new JsonObject(); obj.addProperty("enabled", true); @@ -82,18 +100,19 @@ public class SettingsManager } private void addModule(ClassType keyType, ClassType valueType, boolean bi, String moduleName, JsonObject obj) { - JsonObject result = getObject(data, keyType.getClassPath()); + JsonObject result = getObject(data, keyType.getClassPath(), true); if(bi) { - result = getObject(result, valueType.getClassPath()); + result = getObject(result, valueType.getClassPath(), true); } result.add(moduleName, obj); } - private JsonObject getObject(JsonObject data, String name) { + private JsonObject getObject(JsonObject data, String name, boolean create) { JsonObject obj = data.getAsJsonObject(name); if(obj == null) { obj = new JsonObject(); data.add(name, obj); + if(create) obj.addProperty("enabled", true); } return obj; } diff --git a/src/builder/java/speiger/src/builder/modules/AsyncModule.java b/src/builder/java/speiger/src/builder/modules/AsyncModule.java index 48bb432f..a5f41d8a 100644 --- a/src/builder/java/speiger/src/builder/modules/AsyncModule.java +++ b/src/builder/java/speiger/src/builder/modules/AsyncModule.java @@ -14,11 +14,24 @@ public class AsyncModule extends BaseModule @Override protected void loadFunctions() {} @Override - protected void loadFlags() {} + protected void loadBlockades() { + if(!isModuleEnabled()) { + addBlockedFiles("AsyncBuilder"); + } + } + @Override + protected void loadFlags() { + if(isModuleEnabled()) { + addKeyFlag("ASYNC_MODULE"); + } + } @Override protected void loadClasses() { + //Implementation Classes + addClassMapper("ASYNC_BUILDER", "AsyncBuilder"); + //Abstract Classes addAbstractMapper("BASE_TASK", "Base%sTask"); diff --git a/src/builder/java/speiger/src/builder/modules/BaseModule.java b/src/builder/java/speiger/src/builder/modules/BaseModule.java index 9f55b060..8523dfa1 100644 --- a/src/builder/java/speiger/src/builder/modules/BaseModule.java +++ b/src/builder/java/speiger/src/builder/modules/BaseModule.java @@ -35,6 +35,7 @@ public abstract class BaseModule loadTestClasses(); loadFunctions(); loadRemappers(); + loadBlockades(); loadFlags(); } @@ -50,21 +51,30 @@ public abstract class BaseModule protected abstract void loadTestClasses(); protected abstract void loadFunctions(); protected abstract void loadRemappers(); + protected abstract void loadBlockades(); protected abstract void loadFlags(); public abstract String getModuleName(); public boolean isBiModule() { return false; } public Set getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); } + protected boolean isModuleEnabled() { + return manager == null || manager.isModuleEnabled(this, keyType, valueType); + } + protected boolean isModuleEnabled(String name) { - if(manager == null) return true; - return manager.isModuleEnabled(this, keyType, valueType, name); + return manager == null || manager.isModuleEnabled(this, keyType, valueType, name); } protected void addFlag(String name) { entry.addFlag(name); } + protected void addKeyFlag(String name) { + entry.addFlag(name); + entry.addFlag(keyType.getCapType()+"_"+name); + } + protected void addBiRequirement(String fileName) { entry.addRequirement(fileName, RequiredType.BI_CLASS); entry.addSplitter(fileName, "%1$s2%2$s"); diff --git a/src/builder/java/speiger/src/builder/modules/CollectionModule.java b/src/builder/java/speiger/src/builder/modules/CollectionModule.java index a293840d..03cf9408 100644 --- a/src/builder/java/speiger/src/builder/modules/CollectionModule.java +++ b/src/builder/java/speiger/src/builder/modules/CollectionModule.java @@ -8,11 +8,12 @@ public class CollectionModule extends BaseModule @Override public String getModuleName() { return "Collection"; } @Override - protected void loadVariables() { loadBlockades(); } + protected void loadVariables() {} @Override protected void loadFlags() {} - private void loadBlockades() + @Override + protected void loadBlockades() { if(keyType.isObject()) { addBlockedFiles("Stack"); diff --git a/src/builder/java/speiger/src/builder/modules/FunctionModule.java b/src/builder/java/speiger/src/builder/modules/FunctionModule.java index f6fff714..45562e36 100644 --- a/src/builder/java/speiger/src/builder/modules/FunctionModule.java +++ b/src/builder/java/speiger/src/builder/modules/FunctionModule.java @@ -8,13 +8,14 @@ public class FunctionModule extends BaseModule @Override public boolean isBiModule() { return true; } @Override - protected void loadVariables() { loadBlockades(); } + protected void loadVariables() {} @Override protected void loadFlags() {} @Override protected void loadTestClasses() {} - private void loadBlockades() + @Override + protected void loadBlockades() { if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator"); } diff --git a/src/builder/java/speiger/src/builder/modules/JavaModule.java b/src/builder/java/speiger/src/builder/modules/JavaModule.java index 08344bfb..1ec496e1 100644 --- a/src/builder/java/speiger/src/builder/modules/JavaModule.java +++ b/src/builder/java/speiger/src/builder/modules/JavaModule.java @@ -30,7 +30,9 @@ public class JavaModule extends BaseModule @Override protected void loadRemappers() {} - + @Override + protected void loadBlockades() {} + @Override protected void loadFunctions() { diff --git a/src/builder/java/speiger/src/builder/modules/ListModule.java b/src/builder/java/speiger/src/builder/modules/ListModule.java index c83c3d3b..b1e50cd7 100644 --- a/src/builder/java/speiger/src/builder/modules/ListModule.java +++ b/src/builder/java/speiger/src/builder/modules/ListModule.java @@ -8,11 +8,14 @@ public class ListModule extends BaseModule @Override public String getModuleName() { return "List"; } @Override - protected void loadVariables() { loadBlockedFiles(); } + protected void loadVariables() {} @Override - protected void loadFlags() {} + protected void loadFlags() { + + } - private void loadBlockedFiles() + @Override + protected void loadBlockades() { if(keyType.isObject()) { addBlockedFiles("ListFillBufferTester"); @@ -52,7 +55,6 @@ public class ListModule extends BaseModule //Implementation Classes addClassMapper("ARRAY_LIST", "ArrayList"); addAbstractMapper("COPY_ON_WRITE_LIST", "CopyOnWrite%sArrayList"); - addClassMapper("ASYNC_BUILDER", "AsyncBuilder"); addClassMapper("LINKED_LIST", "LinkedList"); addAbstractMapper("IMMUTABLE_LIST", "Immutable%sList"); diff --git a/src/builder/java/speiger/src/builder/modules/MapModule.java b/src/builder/java/speiger/src/builder/modules/MapModule.java index fc8723f3..b0d11da7 100644 --- a/src/builder/java/speiger/src/builder/modules/MapModule.java +++ b/src/builder/java/speiger/src/builder/modules/MapModule.java @@ -10,11 +10,12 @@ public class MapModule extends BaseModule @Override public boolean isBiModule() { return true; } @Override - protected void loadVariables() { loadBlockades(); } + protected void loadVariables() {} @Override protected void loadFlags() {} - private void loadBlockades() + @Override + protected void loadBlockades() { if(keyType == ClassType.BOOLEAN) { diff --git a/src/builder/java/speiger/src/builder/modules/PairModule.java b/src/builder/java/speiger/src/builder/modules/PairModule.java index 95e85b2c..6af75532 100644 --- a/src/builder/java/speiger/src/builder/modules/PairModule.java +++ b/src/builder/java/speiger/src/builder/modules/PairModule.java @@ -10,6 +10,8 @@ public class PairModule extends BaseModule @Override protected void loadVariables() {} @Override + protected void loadBlockades() {} + @Override protected void loadFlags() {} @Override protected void loadFunctions() {} diff --git a/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java index 81ba212c..0b2d1322 100644 --- a/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java +++ b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java @@ -8,13 +8,14 @@ public class PrioQueueModule extends BaseModule @Override public String getModuleName() { return "PriorityQueue"; } @Override - protected void loadVariables() { loadBlockades(); } + protected void loadVariables() {} @Override protected void loadFlags() {} @Override protected void loadFunctions() {} - private void loadBlockades() + @Override + protected void loadBlockades() { if(keyType == ClassType.BOOLEAN) { addBlockedFiles("QueueTests"); diff --git a/src/builder/java/speiger/src/builder/modules/SetModule.java b/src/builder/java/speiger/src/builder/modules/SetModule.java index 1f3d2d31..5ef11bc3 100644 --- a/src/builder/java/speiger/src/builder/modules/SetModule.java +++ b/src/builder/java/speiger/src/builder/modules/SetModule.java @@ -8,11 +8,12 @@ public class SetModule extends BaseModule @Override public String getModuleName() { return "Set"; } @Override - protected void loadVariables() { loadBlockades(); } + protected void loadVariables() {} @Override protected void loadFlags() {} - private void loadBlockades() + @Override + protected void loadBlockades() { if(keyType == ClassType.BOOLEAN) { diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template index 38ac2290..213b4a9a 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template @@ -23,7 +23,9 @@ import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; #endif +#if ASYNC_MODULE import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER; +#endif import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; import speiger.src.collections.PACKAGE.utils.ITERABLES; import speiger.src.collections.PACKAGE.utils.ITERATORS; @@ -93,6 +95,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable @Override default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); } +#if ASYNC_MODULE /** * Creates a Async Builder for moving work of the thread. * It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread. @@ -103,6 +106,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable return new ASYNC_BUILDERBRACES(this); } +#endif /** * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. * @param mapper the mapping function diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template b/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template index 2de567ec..129637b9 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template @@ -17,27 +17,33 @@ import java.util.Comparator; #endif import speiger.src.collections.PACKAGE.collections.ITERABLE; +#if OBJECT_ASYNC_MODULE import speiger.src.collections.PACKAGE.collections.COLLECTION; +#endif import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.functions.TASK; import speiger.src.collections.PACKAGE.functions.function.PREDICATE; +#if OBJECT_ASYNC_MODULE import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; +#endif import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; +#if OBJECT_ASYNC_MODULE import speiger.src.collections.PACKAGE.lists.LIST; #if !TYPE_BOOLEAN import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; #endif -#if !TYPE_BOOLEAN +#endif +#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE import speiger.src.collections.booleans.utils.BooleanAsyncBuilder; import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask; #endif -#if !TYPE_OBJECT +#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE import speiger.src.collections.objects.utils.ObjectAsyncBuilder; import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask; #endif -#if !TYPE_INT +#if !TYPE_INT && INT_ASYNC_MODULE import speiger.src.collections.ints.utils.IntAsyncBuilder; import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask; #endif @@ -123,6 +129,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values)); } +#if OBJECT_ASYNC_MODULE /** * Maps the elements to something else * @param mapper the mapping function @@ -154,6 +161,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper)); } +#endif /** * Filters out the unwanted elements out of the Iterable * @param filter the elements that should be kept @@ -214,6 +222,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return this; } +#if OBJECT_ASYNC_MODULE /** * Iterates over the Iterable with a desired action * @param action that should be applied @@ -223,6 +232,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ObjectAsyncBuilder<>(new ForEachTask<>(iterable.iterator(), action)); } +#endif /** * Reduces the elements inside of the Iterable down to one element * @param operator that reduces the elements. @@ -257,6 +267,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } #endif +#if OBJECT_ASYNC_MODULE /** * Pours all elements into a List that can be later * @return a new Builder with the pour function applied @@ -285,6 +296,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ObjectAsyncBuilder<>(new CollectTask<>(iterable.iterator(), collection)); } +#endif +#if BOOLEAN_ASYNC_MODULE /** * Searches through the elements of the Iterable to find if the desired element is present. * @param filter that decides the desired elements @@ -312,6 +325,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new BooleanAsyncBuilder(new MatchTaskBRACES(iterable.iterator(), filter, 2)); } +#endif /** * Searches through the elements of the Iterable to find if the desired element. * If not present it will return the default value of the type @@ -323,6 +337,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return this; } +#if INT_ASYNC_MODULE /** * Counts all desired elements inside the Iterable * @param filter that decides the desired elements @@ -332,6 +347,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new IntAsyncBuilder(new CountTaskBRACES(iterable.iterator(), filter)); } +#endif /** * Optional way to add a custom executor that runs this offthread task. * Can only be set after the action was decided on. @@ -512,6 +528,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#if BOOLEAN_ASYNC_MODULE private static class MatchTask KEY_GENERIC_TYPE extends BaseBooleanTask { ITERATOR KEY_GENERIC_TYPE iter; @@ -580,6 +597,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#endif private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE { ITERATOR KEY_GENERIC_TYPE iter; @@ -614,6 +632,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#if INT_ASYNC_MODULE private static class CountTask KEY_GENERIC_TYPE extends BaseIntTask { ITERATOR KEY_GENERIC_TYPE iter; @@ -648,6 +667,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#endif +#if OBJECT_ASYNC_MODULE private static class CollectTask KSS_GENERIC_TYPE> extends BaseObjectTask { ITERATOR KEY_SPECIAL_GENERIC_TYPE iter; @@ -704,6 +725,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#endif /** * Base Task of the Actions that can be performed. * Allows to simplify the actions that get executed.