All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.jarch.apt.generate.DataDetailCodeGenerate 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 DataDetailCodeGenerate extends BaseCodeGenerate {

    public static void generate(Element element, JArchGenerateCrud generateCrud) {
        generate(element, generateCrud.master().name(), generateCrud.nameSubPackage());
    }

    public static void generate(Element element, String useCase, String nameSubPackage) {
        new DataDetailCodeGenerate(element, useCase, nameSubPackage).generate();
    }

    private DataDetailCodeGenerate(Element element, String useCase, String nameSubPackage) {
        super(element, useCase, nameSubPackage);
    }

    @Override
    public ModuleType getModule() {
        return ModuleType.WEB;
    }

    @Override
    public CodeType getType() {
        return CodeType.DATA_DETAIL;
    }

    @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 br.com.jarch.faces.controller.CrudDataDetail;");
        addCode(sbListCode, "import javax.enterprise.context.Dependent;");
        addLineBlank(sbListCode);
    }

    private void addBody(StringBuilder sbListCode) {
        addCode(sbListCode, "@Dependent");
        addCode(sbListCode, "public class " + getName() + " extends CrudDataDetail<" + getNameEntity() + "> {");
        addCode(sbListCode, "}");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy