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

br.com.jarch.apt.processor.SearchTabProcessor Maven / Gradle / Ivy

There is a newer version: 24.9.0
Show newest version
package br.com.jarch.apt.processor;

import br.com.jarch.annotation.*;
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.JArchSearchTab", "br.com.jarch.annotation.JArchSearchTab.List"})
public class SearchTabProcessor extends AbstractProcessor {

    @Override
    public boolean process(final Set annotations, final RoundEnvironment roundEnv) {
        ProcessorUtils.processingEnvironment = processingEnv;
	ProcessorUtils.messageMandatoryWarning("Processando: " + getClass().getSimpleName());
        try {
            roundEnv
                    .getElementsAnnotatedWithAny(Set.of(JArchSearchTab.class, JArchSearchTab.List.class))
                    .stream()
                    .forEach(element -> {
                        ProcessorUtils.messageAnalyzing(getClass(), element);
                        validSearchTab(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 validSearchTab(Element element) {
        final JArchSearchTab[] searchTabs = element.getAnnotationsByType(JArchSearchTab.class);

        for (JArchSearchTab searchTab : searchTabs) {
            for (JArchSearchField searchField : searchTab.searchFields()) {
                ProcessorUtils.validSearchField(element, searchTab, searchField);
            }

            for (JArchSearchFieldCheckbox searchField : searchTab.searchFieldCheckboxes()) {
                ProcessorUtils.validSearchFieldCheckbox(element, searchTab, searchField);
            }

            for (JArchSearchFieldComboboxCommandJpa searchField : searchTab.searchFieldComboboxCommandJpas()) {
                ProcessorUtils.validSearchFieldComboboxCommandJpa(element, searchTab, searchField);
            }

            for (JArchSearchFieldCombobox searchField : searchTab.searchFieldComboboxes()) {
                ProcessorUtils.validSearchFieldCombobox(element, searchTab, searchField);
            }

            for (JArchSearchFieldLookup searchField : searchTab.searchFieldLookups()) {
                ProcessorUtils.validSearchFieldLookup(element, searchTab, searchField);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy