|
|
|
@ -4,20 +4,23 @@ import java.io.IOException;
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
import java.util.function.UnaryOperator;
|
|
|
|
|
|
|
|
|
|
import speiger.src.builder.mappers.InjectMapper;
|
|
|
|
|
import speiger.src.builder.mappers.SimpleMapper;
|
|
|
|
|
import speiger.src.builder.processor.TemplateProcess;
|
|
|
|
|
import speiger.src.builder.processor.TemplateProcessor;
|
|
|
|
|
|
|
|
|
|
public class TestBuilder extends TemplateProcessor
|
|
|
|
|
{
|
|
|
|
|
Map<String, List<UnaryOperator<String>>> data;
|
|
|
|
|
public static final String[] KEY_TYPE = new String[]{"byte", "short", "int", "long", "float", "double", "T"};
|
|
|
|
|
public static final String[] CLASS_TYPE = new String[]{"Byte", "Short", "Integer", "Long", "Float", "Double", "Object"};
|
|
|
|
|
public static final String[] FILE_TYPE = new String[]{"Byte", "Short", "Int", "Long", "Float", "Double", "Object"};
|
|
|
|
|
|
|
|
|
|
List<GlobalVariables> varibles = new ArrayList<GlobalVariables>();
|
|
|
|
|
|
|
|
|
|
public TestBuilder()
|
|
|
|
|
{
|
|
|
|
@ -30,26 +33,34 @@ public class TestBuilder extends TemplateProcessor
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean relativePackages()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void init()
|
|
|
|
|
{
|
|
|
|
|
data = new LinkedHashMap<>();
|
|
|
|
|
data.put("Byte", createForType("byte", "Byte", "Byte"));
|
|
|
|
|
data.put("Short", createForType("short", "Short", "Short"));
|
|
|
|
|
data.put("Int", createForType("int", "Integer", "Int"));
|
|
|
|
|
data.put("Long", createForType("long", "Long", "Long"));
|
|
|
|
|
data.put("Float", createForType("float", "Float", "Float"));
|
|
|
|
|
data.put("Double", createForType("double", "Double", "Double"));
|
|
|
|
|
data.put("Object", createForType("Object", "T", "Object"));
|
|
|
|
|
varibles.clear();
|
|
|
|
|
for(int i = 0,m=KEY_TYPE.length;i<m;i++)
|
|
|
|
|
{
|
|
|
|
|
GlobalVariables type = new GlobalVariables(FILE_TYPE[i]);
|
|
|
|
|
type.createInitials(CLASS_TYPE[i], KEY_TYPE[i]);
|
|
|
|
|
type.createClassTypes(FILE_TYPE[i]);
|
|
|
|
|
varibles.add(type);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<UnaryOperator<String>> createForType(String lowercase, String upperCase, String classType)
|
|
|
|
|
private List<UnaryOperator<String>> createForType(String lowercase, String upperCase, String classType, String consumer)
|
|
|
|
|
{
|
|
|
|
|
Files
|
|
|
|
|
List<UnaryOperator<String>> list = new ArrayList<>();
|
|
|
|
|
list.add(new SimpleMapper("LIST", classType+"List"));
|
|
|
|
|
list.add(new SimpleMapper("JAVA_CONSUMER", "java.util.function."+consumer));
|
|
|
|
|
list.add(new SimpleMapper("CONSUMER", classType+"Consumer"));
|
|
|
|
|
list.add(new SimpleMapper("CLASS_TYPE", upperCase));
|
|
|
|
|
list.add(new SimpleMapper("KEY_TYPE", lowercase));
|
|
|
|
|
list.add(new SimpleMapper("KEY_GENERIC_TYPE", "<T>"));
|
|
|
|
|
list.add(new InjectMapper("OBJ_TO_KEY(\\([^)]+\\)|\\S)", "%s."+lowercase+"Value()").removeBraces());
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -60,27 +71,31 @@ public class TestBuilder extends TemplateProcessor
|
|
|
|
|
{
|
|
|
|
|
TemplateProcess process = new TemplateProcess(entry.getKey()+name+".java", Paths.get(""));
|
|
|
|
|
process.addMappers(entry.getValue());
|
|
|
|
|
if(entry.getKey().equals("Object"))
|
|
|
|
|
{
|
|
|
|
|
process.addFlags("OBJECT");
|
|
|
|
|
}
|
|
|
|
|
acceptor.accept(process);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String...args)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
new TestBuilder().process(true);
|
|
|
|
|
}
|
|
|
|
|
catch(InterruptedException e)
|
|
|
|
|
Path path = Paths.get("").toAbsolutePath();
|
|
|
|
|
System.out.println(path.toString());
|
|
|
|
|
for(int i = 0,m=path.getNameCount();i<m;i++)
|
|
|
|
|
{
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
catch(IOException e)
|
|
|
|
|
{
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
System.out.println(path.getName(i).toString());
|
|
|
|
|
}
|
|
|
|
|
// try
|
|
|
|
|
// {
|
|
|
|
|
// new TestBuilder().process(true);
|
|
|
|
|
// }
|
|
|
|
|
// catch(InterruptedException e)
|
|
|
|
|
// {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// catch(IOException e)
|
|
|
|
|
// {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|