use of org.jboss.forge.roaster.model.source.JavaClassSource in project Entitas-Java by Rubentxu.
the class EntitasGenerator method generateEntitas.
public JavaClassSource generateEntitas(Set<String> contextNames, String pkgDestiny) {
JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, "public class Entitas implements IContexts{}");
javaClass.setPackage(pkgDestiny);
createMethodConstructor(javaClass, contextNames);
createContextsMethod(javaClass, contextNames);
createMethodAllContexts(javaClass, contextNames);
createContextFields(javaClass, contextNames);
return javaClass;
}
use of org.jboss.forge.roaster.model.source.JavaClassSource in project Entitas-Java by Rubentxu.
the class MatcherGenerator method generateMatchers.
private JavaClassSource generateMatchers(String contextName, List<ComponentInfo> componentInfos, String pkgDestiny) {
JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$s {}", CodeGeneratorOld.capitalize(contextName) + "Matcher"));
if (componentInfos.size() > 0 && !pkgDestiny.endsWith(componentInfos.get(0).subDir)) {
pkgDestiny += "." + componentInfos.get(0).subDir;
}
javaClass.setPackage(pkgDestiny);
// javaClass.addImport("com.ilargia.games.entitas.interfaces.IMatcher");
javaClass.addImport("Matcher");
for (ComponentInfo info : componentInfos) {
addMatcher(contextName, info, javaClass);
addMatcherMethods(contextName, info, javaClass);
}
System.out.println(javaClass);
return javaClass;
}
use of org.jboss.forge.roaster.model.source.JavaClassSource in project Entitas-Java by Rubentxu.
the class ContextGenerator method generateContext.
private JavaClassSource generateContext(String contextName, List<ComponentInfo> infos, String pkgDestiny) {
JavaClassSource contextClass = Roaster.parse(JavaClassSource.class, String.format("public class %1$sContext extends Context<%1$sEntity> {}", contextName));
// }
if (infos.size() > 0 && !pkgDestiny.endsWith(infos.get(0).subDir)) {
pkgDestiny += "." + infos.get(0).subDir;
}
contextClass.setPackage(pkgDestiny);
contextClass.addMethod().setName(contextName + "Context").setPublic().setConstructor(true).setParameters(String.format("int totalComponents, int startCreationIndex, ContextInfo contextInfo, EntityBaseFactory<%1$sEntity> factoryMethod", contextName)).setBody("super(totalComponents, startCreationIndex, contextInfo, factoryMethod);");
contextClass.addImport("ilargia.entitas.api.*");
for (ComponentInfo info : infos) {
if (info.isSingleEntity) {
addContextMethods(contextName, info, contextClass);
}
}
return contextClass;
}
use of org.jboss.forge.roaster.model.source.JavaClassSource in project Entitas-Java by Rubentxu.
the class EntitasGenerator method generateEntitas.
public JavaClassSource generateEntitas(Set<String> contextNames, String pkgDestiny) {
JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, "public class Entitas implements IContexts{}");
javaClass.setPackage(pkgDestiny);
createMethodConstructor(javaClass, contextNames);
createContextsMethod(javaClass, contextNames);
createMethodAllContexts(javaClass, contextNames);
createContextFields(javaClass, contextNames);
return javaClass;
}
use of org.jboss.forge.roaster.model.source.JavaClassSource in project Entitas-Java by Rubentxu.
the class ComponentEntityGenerator method generateEntity.
private void generateEntity(String contextName, ComponentData data) {
String pkgDestiny = targetPackageConfig.getTargetPackage();
CodeGenFile<JavaClassSource> genFile = getCodeGenFile(contextName, data);
JavaClassSource codeGenerated = genFile.getFileContent();
if (!pkgDestiny.endsWith(data.getSubDir())) {
pkgDestiny += "." + data.getSubDir();
}
if (codeGenerated.getPackage() == null) {
codeGenerated.setPackage(pkgDestiny);
codeGenerated.addMethod().setName(contextName + "Entity").setPublic().setConstructor(true).setBody("");
codeGenerated.addImport("ilargia.entitas.Entity");
}
if (shouldGenerateMethods(data)) {
addImporEnums(data, codeGenerated);
addEntityMethods(contextName, data, codeGenerated);
}
if (isSharedContext(data) && codeGenerated.getImport(targetPackageConfig.getTargetPackage()) == null) {
codeGenerated.addImport(targetPackageConfig.getTargetPackage() + ".SharedComponentsLookup");
}
}
Aggregations