br.com.jarch.apt.processor.ColumnsDataTableProcessor Maven / Gradle / Ivy
The newest version!
package br.com.jarch.apt.processor;
import br.com.jarch.core.annotation.JArchColumnDataTable;
import br.com.jarch.core.annotation.JArchColumnsDataTable;
import br.com.jarch.apt.util.ProcessorUtils;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import java.util.Set;
@SupportedAnnotationTypes({"br.com.jarch.core.annotation.JArchColumnsDataTable", "br.com.jarch.core.annotation.JArchColumnsDataTable.List"})
public class ColumnsDataTableProcessor extends AbstractProcessor {
@Override
public boolean process(final Set extends TypeElement> annotations, final RoundEnvironment roundEnv) {
try {
ProcessorUtils.processingEnvironment = processingEnv;
ProcessorUtils.messageNote("Analyzing: " + getClass().getSimpleName());
roundEnv
.getElementsAnnotatedWithAny(Set.of(JArchColumnsDataTable.class, JArchColumnsDataTable.List.class))
.stream()
.forEach(element -> {
ProcessorUtils.messageAnalyzing(getClass(), element);
validColumnsDataTable(element);
});
} catch (Exception ex) {
ProcessorUtils.messageError("JARCH ERROR: Erro no APT " + getClass().getSimpleName() + " Mensagem: " + ex.getMessage());
}
return false;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
private void validColumnsDataTable(Element element) {
JArchColumnsDataTable[] columnsDataTables = element.getAnnotationsByType(JArchColumnsDataTable.class);
for (JArchColumnsDataTable columnsDataTable : columnsDataTables) {
for (JArchColumnDataTable columnDataTable : columnsDataTable.columns()) {
ProcessorUtils.validColumnDataTable(element, columnsDataTable, columnDataTable);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy