br.com.jarch.apt.processor.SearchFieldProcessor Maven / Gradle / Ivy
package br.com.jarch.apt.processor;
import br.com.jarch.annotation.JArchSearchField;
import br.com.jarch.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.annotation.JArchSearchField", "br.com.jarch.annotation.JArchSearchField.List"})
public class SearchFieldProcessor extends AbstractProcessor {
@Override
public boolean process(final Set extends TypeElement> annotations, final RoundEnvironment roundEnv) {
ProcessorUtils.processingEnvironment = processingEnv;
ProcessorUtils.messageMandatoryWarning("Processando: " + getClass().getSimpleName());
try {
roundEnv
.getElementsAnnotatedWithAny(Set.of(JArchSearchField.class, JArchSearchField.List.class))
.stream()
.forEach(element -> {
ProcessorUtils.messageAnalyzing(getClass(), element);
validSearchField(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 validSearchField(Element element) {
final JArchSearchField[] searchFields = element.getAnnotationsByType(JArchSearchField.class);
for (JArchSearchField searchField : searchFields) {
ProcessorUtils.validSearchField(element, null, searchField);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy