Finished adding the modules and implemented sorting algorythm.

That this works is crazy...
This commit is contained in:
Speiger 2022-11-29 14:33:16 +01:00
parent b065ebe9ba
commit 8e39acef45
14 changed files with 581 additions and 47 deletions

View File

@ -1,6 +1,8 @@
package speiger.src.builder.modules;
package speiger.src.builder;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -8,6 +10,16 @@ import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import speiger.src.builder.modules.AsyncModule;
import speiger.src.builder.modules.BaseModule;
import speiger.src.builder.modules.CollectionModule;
import speiger.src.builder.modules.FunctionModule;
import speiger.src.builder.modules.JavaModule;
import speiger.src.builder.modules.ListModule;
import speiger.src.builder.modules.MapModule;
import speiger.src.builder.modules.PairModule;
import speiger.src.builder.modules.PrioQueueModule;
import speiger.src.builder.modules.SetModule;
import speiger.src.builder.processor.TemplateProcess;
import speiger.src.builder.processor.TemplateProcessor;
@ -19,6 +31,27 @@ public class ModuleBuilder extends TemplateProcessor
List<ModulePackage> enumPackages = new ArrayList<>();
Map<String, RequiredType> requirements = new HashMap<>();
public static void main(String...args)
{
try
{
new ModuleBuilder(true).process(true);
}
catch(IOException e)
{
e.printStackTrace();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
public ModuleBuilder(boolean silencedSuccess)
{
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
}
public ModuleBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder)
{
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
@ -29,6 +62,15 @@ public class ModuleBuilder extends TemplateProcessor
{
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());
finishPackages();
}

View File

@ -1,7 +1,8 @@
package speiger.src.builder.modules;
package speiger.src.builder;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@ -14,7 +15,6 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
import speiger.src.builder.ClassType;
import speiger.src.builder.mappers.IMapper;
import speiger.src.builder.processor.TemplateProcess;
@ -38,6 +38,7 @@ public class ModulePackage
}
public void finish() {
mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed()));
mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort));
}
@ -77,8 +78,8 @@ public class ModulePackage
blockedFilters.add(filter);
}
public void addBlockedFile(String name) {
blocked.add(name);
public void addBlockedFiles(String... names) {
blocked.addAll(Arrays.asList(names));
}
public void addSplitter(String fileName, String splitter) {
@ -93,7 +94,7 @@ public class ModulePackage
if(isBlocked(fileName)) return;
String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType());
String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter);
TemplateProcess process = new TemplateProcess(newName);
TemplateProcess process = new TemplateProcess(newName+".java");
process.setPathBuilder(new PathBuilder(keyType.getPathType()));
process.addFlags(flags);
process.addMappers(mappers);
@ -119,7 +120,6 @@ public class ModulePackage
}
private int sort(String key, String value) {
if(key.equals(value)) return 0;
if(value.contains(key)) return 1;
else if(key.contains(value)) return -1;
return 0;

View File

@ -326,7 +326,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
{
Set<String> flags = new HashSet<>(Arrays.asList(args));
boolean silent = flags.contains("silent");
boolean force = flags.contains("force");
boolean force = !flags.contains("force");
boolean tests = flags.contains("tests");
boolean forceTests = flags.contains("force-tests");
// new PrimitiveCollectionsBuilder(silent).test();

View File

@ -1,4 +1,4 @@
package speiger.src.builder.modules;
package speiger.src.builder;
@SuppressWarnings("javadoc")
public enum RequiredType

View File

@ -0,0 +1,26 @@
package speiger.src.builder.modules;
@SuppressWarnings("javadoc")
public class AsyncModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadClasses();
}
@Override
protected void loadFlags()
{
}
private void loadClasses()
{
//Abstract Classes
addAbstractMapper("BASE_TASK", "Base%sTask");
//Interfaces
addClassMapper("TASK", "Task");
}
}

View File

@ -3,6 +3,8 @@ package speiger.src.builder.modules;
import java.util.function.Predicate;
import speiger.src.builder.ClassType;
import speiger.src.builder.ModulePackage;
import speiger.src.builder.RequiredType;
import speiger.src.builder.mappers.ArgumentMapper;
import speiger.src.builder.mappers.InjectMapper;
import speiger.src.builder.mappers.LineMapper;
@ -43,6 +45,12 @@ public abstract class BaseModule
entry.addSplitter(fileName, "%1$s2%2$s");
}
protected void addEnumRequirement(String fileName) {
entry.addRequirement(fileName, RequiredType.ENUM);
entry.addSplitter(fileName, "%2$s");
}
protected void addBiRequirement(String fileName, String splitter) {
entry.addRequirement(fileName, RequiredType.BI_CLASS);
entry.addSplitter(fileName, "%1$s"+splitter+"%2$s");
@ -53,105 +61,91 @@ public abstract class BaseModule
entry.addSplitter(fileName, splitter);
}
protected void addBlockedFile(String name)
{
entry.addBlockedFile(name);
protected void addRemapper(String fileName, String actualName) {
entry.addRemapper(fileName, actualName);
}
protected void addBlockedFilter(Predicate<String> filter)
{
protected void addBlockedFiles(String... name) {
entry.addBlockedFiles(name);
}
protected void addBlockedFilter(Predicate<String> filter) {
entry.addBlockedFilter(filter);
}
protected void addClassMapper(String pattern, String replacement)
{
protected void addClassMapper(String pattern, String replacement) {
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+replacement));
entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+replacement));
}
protected void addBiClassMapper(String pattern, String replacement, String splitter)
{
protected void addBiClassMapper(String pattern, String replacement, String splitter) {
entry.addMapper(new SimpleMapper("KEY_"+pattern, "KEY_"+pattern, keyType.getFileType()+splitter+keyType.getFileType()+replacement));
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+splitter+valueType.getFileType()+replacement));
entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+splitter+valueType.getFileType()+replacement));
}
protected void addAbstractMapper(String pattern, String replacement)
{
protected void addAbstractMapper(String pattern, String replacement) {
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getFileType())));
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType())));
}
protected void addAbstractBiMapper(String pattern, String replacement, String splitter)
{
protected void addAbstractBiMapper(String pattern, String replacement, String splitter) {
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType()+splitter+valueType.getFileType())));
}
protected void addFunctionMapper(String pattern, String replacement)
{
protected void addFunctionMapper(String pattern, String replacement) {
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, replacement+valueType.getNonFileType()));
entry.addMapper(new SimpleMapper(pattern, pattern, replacement+keyType.getNonFileType()));
}
protected void addFunctionValueMapper(String pattern, String replacement)
{
protected void addFunctionValueMapper(String pattern, String replacement) {
entry.addMapper(new SimpleMapper(pattern, pattern, replacement+valueType.getNonFileType()));
}
protected void addFunctionMappers(String pattern, String replacement)
{
protected void addFunctionMappers(String pattern, String replacement) {
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getNonFileType())));
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getNonFileType())));
}
protected void addFunctionValueMappers(String pattern, String replacement)
{
protected void addFunctionValueMappers(String pattern, String replacement) {
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, valueType.getNonFileType())));
}
protected void addSimpleMapper(String pattern, String replacement)
{
protected void addSimpleMapper(String pattern, String replacement) {
entry.addMapper(new SimpleMapper(pattern, pattern, replacement));
}
protected void addAnnontion(String pattern, String value)
{
protected void addAnnontion(String pattern, String value) {
if(keyType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern));
else entry.addMapper(new SimpleMapper(pattern, pattern, value));
}
protected void addValueAnnontion(String pattern, String value)
{
protected void addValueAnnontion(String pattern, String value) {
if(valueType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern));
else entry.addMapper(new SimpleMapper(pattern, pattern, value));
}
protected void addComment(String pattern, String value)
{
protected void addComment(String pattern, String value) {
if(keyType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces());
else entry.addMapper(new LineMapper(pattern, pattern));
}
protected void addValueComment(String pattern, String value)
{
protected void addValueComment(String pattern, String value) {
if(valueType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces());
else entry.addMapper(new LineMapper(pattern, pattern));
}
protected InjectMapper addInjectMapper(String pattern, String replacement)
{
protected InjectMapper addInjectMapper(String pattern, String replacement) {
InjectMapper mapper = new InjectMapper(pattern, pattern, replacement);
entry.addMapper(mapper);
return mapper;
}
protected ArgumentMapper addArgumentMapper(String pattern, String replacement)
{
protected ArgumentMapper addArgumentMapper(String pattern, String replacement) {
return addArgumentMapper(pattern, replacement, ", ");
}
protected ArgumentMapper addArgumentMapper(String pattern, String replacement, String splitter)
{
protected ArgumentMapper addArgumentMapper(String pattern, String replacement, String splitter) {
ArgumentMapper mapper = new ArgumentMapper(pattern, pattern, replacement, splitter);
entry.addMapper(mapper);
return mapper;

View File

@ -0,0 +1,64 @@
package speiger.src.builder.modules;
@SuppressWarnings("javadoc")
public class CollectionModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadClasses();
loadFunctions();
loadRemappers();
loadBlockades();
}
@Override
protected void loadFlags()
{
}
private void loadBlockades()
{
if(keyType.isObject()) addBlockedFiles("Stack");
}
private void loadRemappers()
{
addRemapper("IArray", "I%sArray");
addRemapper("AbstractCollection", "Abstract%sCollection");
}
private void loadFunctions()
{
addFunctionMapper("NEXT", "next");
addSimpleMapper("NEW_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getKeyType()+"Stream");
addFunctionMapper("PREVIOUS", "previous");
addFunctionMapper("REMOVE_KEY", "rem");
addSimpleMapper("TO_ARRAY", "to"+keyType.getNonFileType()+"Array");
addSimpleMapper("VALUE_TO_ARRAY", "to"+valueType.getNonFileType()+"Array");
}
private void loadClasses()
{
//Abstract Classes
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
//Helper Classes
addClassMapper("ARRAYS", "Arrays");
addClassMapper("COLLECTIONS", "Collections");
addClassMapper("ITERABLES", "Iterables");
addClassMapper("SPLIT_ITERATORS", "Splititerators");
addClassMapper("ITERATORS", "Iterators");
//Interfaces
addClassMapper("COLLECTION", "Collection");
addClassMapper("ITERABLE", "Iterable");
addClassMapper("SPLIT_ITERATOR", "Splititerator");
addClassMapper("LIST_ITERATOR", "ListIterator");
addClassMapper("BI_ITERATOR", "BidirectionalIterator");
addClassMapper("ITERATOR", "Iterator");
addClassMapper("STACK", "Stack");
addClassMapper("STRATEGY", "Strategy");
}
}

View File

@ -0,0 +1,72 @@
package speiger.src.builder.modules;
@SuppressWarnings("javadoc")
public class FunctionModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadFunctions();
loadClasses();
loadRemappers();
loadBlockades();
}
@Override
protected void loadFlags()
{
}
private void loadBlockades()
{
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
}
private void loadRemappers()
{
addBiRequirement("BiConsumer", "");
addBiRequirement("UnaryOperator", "");
addBiRequirement("Function");
addRemapper("BiConsumer", "%sConsumer");
}
private void loadFunctions()
{
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
addSimpleMapper("TEST_VALUE", keyType.isObject() ? "getBoolean" : "get");
}
private void loadClasses()
{
//Interfaces
addBiClassMapper("BI_CONSUMER", "Consumer", "");
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
addClassMapper("TO_OBJECT_FUNCTION", "2ObjectFunction");
addBiClassMapper("FUNCTION", "Function", "2");
addClassMapper("PREDICATE", "2BooleanFunction");
addClassMapper("SUPPLIER", "Supplier");
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
if(keyType.isObject())
{
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
addSimpleMapper("CONSUMER", "Consumer");
addSimpleMapper("IARRAY", "IObjectArray");
}
else
{
if(valueType.isObject())
{
addSimpleMapper("VALUE_CONSUMER", "Consumer");
addSimpleMapper("CONSUMER", keyType.getFileType()+"Consumer");
}
else addClassMapper("CONSUMER", "Consumer");
addFunctionMappers("IARRAY", "I%sArray");
}
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
addSimpleMapper("COMPARATOR", keyType.isObject() ? "Comparator" : String.format("%sComparator", keyType.getNonFileType()));
}
}

View File

@ -8,10 +8,11 @@ public class JavaModule extends BaseModule
@Override
protected void loadVariables()
{
loadBaseVariables();
createHelperVars(keyType, false, "KEY");
createHelperVars(valueType, true, "VALUE");
loadBaseVariables();
loadClasses();
loadFunctions();
}
@Override
@ -29,7 +30,16 @@ public class JavaModule extends BaseModule
private void loadFunctions()
{
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
addSimpleMapper("APPLY", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
//Shared by Maps and Pairs so moved to java.
addFunctionMappers("ENTRY_KEY", "get%sKey");
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
addFunctionMappers("KEY_ENTRY", "set%sKey");
addFunctionValueMappers("VALUE_ENTRY", "set%sValue");
}
private void loadClasses()
@ -138,6 +148,7 @@ public class JavaModule extends BaseModule
{
addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType());
}
addSimpleMapper("[SPACE]", " ");
addComment("@ArrayType", "@param <%s> the keyType of array that the operation should be applied");
addComment("@Type", "@param <%s> the keyType of elements maintained by this Collection");
addValueComment("@ValueArrayType", "@param <%s> the keyType of array that the operation should be applied");

View File

@ -0,0 +1,62 @@
package speiger.src.builder.modules;
@SuppressWarnings("javadoc")
public class ListModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadClasses();
loadFunctions();
loadRemappers();
}
@Override
protected void loadFlags()
{
}
private void loadRemappers()
{
addRemapper("AbstractList", "Abstract%sList");
addRemapper("ImmutableList", "Immutable%sList");
addRemapper("CopyOnWriteList", "CopyOnWrite%sArrayList");
}
private void loadFunctions()
{
addFunctionMapper("GET_KEY", "get");
addFunctionMapper("REMOVE_LAST", "removeLast");
addFunctionMapper("REMOVE_SWAP", "swapRemove");
addFunctionMappers("REPLACE", keyType.isObject() ? "replaceObjects" : "replace%ss");
addFunctionMappers("SORT", "sort%ss");
}
private void loadClasses()
{
//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");
//Abstract Classes
addAbstractMapper("ABSTRACT_LIST", "Abstract%sList");
//SubClasses
addClassMapper("SUB_LIST", "SubList");
addClassMapper("LIST_ITER", "ListIter");
//Helper Classes
addClassMapper("LISTS", "Lists");
//Interfaces
addClassMapper("LIST", "List");
}
}

View File

@ -0,0 +1,115 @@
package speiger.src.builder.modules;
import speiger.src.builder.ClassType;
@SuppressWarnings("javadoc")
public class MapModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadFunctions();
loadClasses();
loadRemappers();
loadBlockades();
}
@Override
protected void loadFlags()
{
}
private void loadBlockades()
{
if(keyType == ClassType.BOOLEAN)
{
addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap");
addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap");
addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
addBlockedFiles("ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap");
}
}
private void loadRemappers()
{
addBiRequirement("Map");
addBiRequirement("SortedMap");
addBiRequirement("OrderedMap");
addBiRequirement("NavigableMap");
addBiRequirement("ConcurrentMap");
addBiRequirement("AbstractMap");
addEnumRequirement("EnumMap");
addEnumRequirement("LinkedEnumMap");
addBiRequirement("ConcurrentOpenHashMap");
addBiRequirement("ImmutableOpenHashMap");
addBiRequirement("OpenHashMap");
addBiRequirement("LinkedOpenHashMap");
addBiRequirement("OpenCustomHashMap");
addBiRequirement("LinkedOpenCustomHashMap");
addBiRequirement("ArrayMap");
addBiRequirement("RBTreeMap");
addBiRequirement("AVLTreeMap");
addBiRequirement("Maps");
addRemapper("AbstractMap", "Abstract%sMap");
addRemapper("EnumMap", "Enum2%sMap");
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
}
private void loadFunctions()
{
addFunctionValueMapper("BULK_MERGE", "mergeAll");
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
addFunctionValueMapper("COMPUTE", "compute");
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
addFunctionMapper("DEQUEUE", "dequeue");
addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
else addSimpleMapper("GET_VALUE", "get");
addSimpleMapper("GET_JAVA", keyType.isObject() ? "get" : "getAs"+keyType.getCustomJDKType().getNonFileType());
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
addFunctionValueMapper("MERGE", "merge");
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
else addSimpleMapper("REMOVE_VALUE", "remove");
addFunctionMapper("REMOVE", "remove");
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
}
private void loadClasses()
{
//Implementation Classes
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
//Abstract Classes
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
//Helper Classes
addBiClassMapper("MAPS", "Maps", "2");
//Interfaces
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
addBiClassMapper("MAP", "Map", "2");
}
}

View File

@ -0,0 +1,35 @@
package speiger.src.builder.modules;
@SuppressWarnings("javadoc")
public class PairModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadClasses();
loadRemappers();
}
@Override
protected void loadFlags()
{
}
private void loadRemappers()
{
addBiRequirement("Pair", "");
addBiRequirement("MutablePair", "");
addBiRequirement("ImmutablePair", "");
}
private void loadClasses()
{
//Implementations
addBiClassMapper("IMMUTABLE_PAIR", "ImmutablePair", "");
addBiClassMapper("MUTABLE_PAIR", "MutablePair", "");
//Interfaces
addBiClassMapper("PAIR", "Pair", "");
}
}

View File

@ -0,0 +1,42 @@
package speiger.src.builder.modules;
@SuppressWarnings("javadoc")
public class PrioQueueModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadClasses();
loadReampper();
}
@Override
protected void loadFlags()
{
}
private void loadReampper()
{
addRemapper("AbstractPriorityQueue", "Abstract%sPriorityQueue");
}
private void loadClasses()
{
//Implementation Classes
addClassMapper("ARRAY_FIFO_QUEUE", "ArrayFIFOQueue");
addClassMapper("ARRAY_PRIORITY_QUEUE", "ArrayPriorityQueue");
addClassMapper("HEAP_PRIORITY_QUEUE", "HeapPriorityQueue");
//Abstract Classes
addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue");
//Helper Classes
addClassMapper("PRIORITY_QUEUES", "PriorityQueues");
//Interfaces
addClassMapper("PRIORITY_QUEUE", "PriorityQueue");
addClassMapper("PRIORITY_DEQUEUE", "PriorityDequeue");
}
}

View File

@ -0,0 +1,71 @@
package speiger.src.builder.modules;
import speiger.src.builder.ClassType;
@SuppressWarnings("javadoc")
public class SetModule extends BaseModule
{
@Override
protected void loadVariables()
{
loadClasses();
loadFunctions();
loadReamppers();
loadBlockades();
}
@Override
protected void loadFlags()
{
}
private void loadBlockades()
{
if(keyType == ClassType.BOOLEAN)
{
addBlockedFiles("SortedSet", "NavigableSet", "AVLTreeSet", "RBTreeSet");
addBlockedFiles("OrderedSet", "ArraySet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
addBlockedFiles("OpenHashSet", "OpenCustomHashSet", "ImmutableOpenHashSet");
}
}
private void loadReamppers()
{
addRemapper("AbstractSet", "Abstract%sSet");
addRemapper("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
}
private void loadFunctions()
{
addFunctionMapper("POLL_FIRST_KEY", "pollFirst");
addFunctionMapper("POLL_LAST_KEY", "pollLast");
addFunctionMapper("FIRST_KEY", "first");
addFunctionMapper("LAST_KEY", "last");
}
private void loadClasses()
{
//Implementation Classes
addClassMapper("LINKED_CUSTOM_HASH_SET", "LinkedOpenCustomHashSet");
addClassMapper("LINKED_HASH_SET", "LinkedOpenHashSet");
addAbstractMapper("IMMUTABLE_HASH_SET", "Immutable%sOpenHashSet");
addClassMapper("CUSTOM_HASH_SET", "OpenCustomHashSet");
addClassMapper("HASH_SET", "OpenHashSet");
addClassMapper("RB_TREE_SET", "RBTreeSet");
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
addClassMapper("ARRAY_SET", "ArraySet");
//Abstract Classes
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
//Helper Classes
addClassMapper("SETS", "Sets");
//Interfaces
addClassMapper("NAVIGABLE_SET", "NavigableSet");
addClassMapper("SORTED_SET", "SortedSet");
addClassMapper("ORDERED_SET", "OrderedSet");
addClassMapper("SET", "Set");
}
}