br.com.jarch.apt.generate.RestCodeGenerate Maven / Gradle / Ivy
The newest version!
package br.com.jarch.apt.generate;
import br.com.jarch.apt.type.CodeType;
import br.com.jarch.apt.type.ModuleType;
import br.com.jarch.core.annotation.JArchGenerateCrud;
import javax.lang.model.element.Element;
import static br.com.jarch.apt.util.ProcessorUtils.addCode;
import static br.com.jarch.apt.util.ProcessorUtils.addLineBlank;
public class RestCodeGenerate extends BaseCodeGenerate {
public static void generate(Element element, JArchGenerateCrud generateCrud) {
new RestCodeGenerate(element, generateCrud).generate();
}
RestCodeGenerate(Element element, JArchGenerateCrud generateCrud) {
super(element, generateCrud);
}
@Override
public ModuleType getModule() {
return ModuleType.WS;
}
@Override
public CodeType getType() {
return CodeType.REST;
}
@Override
public String getContent() {
StringBuilder code = new StringBuilder();
addPackage(code);
addImports(code);
addBody(code);
return code.toString();
}
private void addPackage(StringBuilder sbListCode) {
addCode(sbListCode, "package " + getNamePackage() + ";");
addLineBlank(sbListCode);
}
private void addImports(StringBuilder sbListCode) {
addCode(sbListCode, "import " + getFullNameEntity() + ";");
addCode(sbListCode, "import " + getFullNameService() + ";");
addCode(sbListCode, "import " + getFullNameRepository() + ";");
addCode(sbListCode, "import " + getFullNameSearch() + ";");
addCode(sbListCode, "import br.com.jarch.core.annotation.JArchRest;");
addCode(sbListCode, "import br.com.jarch.core.crud.rest.BaseRest;");
addCode(sbListCode, "import io.swagger.annotations.Api;");
addCode(sbListCode, "import javax.ws.rs.Path;");
addLineBlank(sbListCode);
}
private void addBody(StringBuilder sbListCode) {
addCode(sbListCode, "@Api");
addCode(sbListCode, "@Path(\"" + getVarName() + "\")");
addCode(sbListCode, "@JArchRest");
addCode(sbListCode, "public class " + getName() + " extends BaseRest<" + getNameEntity() + ", " + getNameService() + ", " + getNameRepository() + ", " + getNameSearch() + "> {");
addCode(sbListCode, "}");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy