br.com.jarch.apt.generate.ListControllerCodeGenerate Maven / Gradle / Ivy
package br.com.jarch.apt.generate;
import br.com.jarch.util.type.CodeType;
import br.com.jarch.util.type.ModuleType;
import javax.lang.model.element.Element;
import static br.com.jarch.util.ProcessorUtils.addCode;
import static br.com.jarch.util.ProcessorUtils.addLineBlank;
public class ListControllerCodeGenerate extends BaseCodeGenerate {
public static void generate(Element element, String useCase, String nameSubPackage) {
new ListControllerCodeGenerate(element, useCase, nameSubPackage).generate();
}
ListControllerCodeGenerate(Element element, String useCase, String nameSubPackage) {
super(element, useCase, nameSubPackage);
}
@Override
public ModuleType getModule() {
return ModuleType.WEB;
}
@Override
public CodeType getType() {
return CodeType.LIST_CONTROLLER;
}
@Override
public String getContent() {
StringBuilder sbListCode = new StringBuilder();
addPackage(sbListCode);
addImports(sbListCode);
addBody(sbListCode);
return sbListCode.toString();
}
private void addPackage(StringBuilder sbListCode) {
addCode(sbListCode, "package " + getNamePackage() + ";");
addLineBlank(sbListCode);
}
private void addImports(StringBuilder sbListCode) {
addCode(sbListCode, "import br.com.jarch.annotation.JArchListController;");
addCode(sbListCode, "import br.com.jarch.faces.controller.CrudListController;");
addCode(sbListCode, "import " + getFullNameEntity() +";");
addCode(sbListCode, "import " + getFullNameService() +";");
addCode(sbListCode, "import " + getFullNameRepository() +";");
addLineBlank(sbListCode);
}
private void addBody(StringBuilder sbListCode) {
addCode(sbListCode, "@JArchListController");
addCode(sbListCode, "public class " + getName() + " extends CrudListController<" + getNameEntity() + ", " + getNameService() + ", " + getNameRepository() + "> {");
addLineBlank(sbListCode);
addCode(sbListCode, "\t@Override");
addCode(sbListCode, "\tpublic String getPageData() {");
addCode(sbListCode, "\t\treturn \"" + getVarName() + "Data.jsf\";");
addCode(sbListCode, "\t}");
addCode(sbListCode, "}");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy