br.com.jarch.apt.processor.ManyToOneProcessor Maven / Gradle / Ivy
The newest version!
package br.com.jarch.apt.processor;
import br.com.jarch.core.annotation.JArchExclusionLogic;
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 javax.persistence.ManyToOne;
import java.util.Set;
@SupportedAnnotationTypes("javax.persistence.ManyToOne")
public class ManyToOneProcessor extends AbstractProcessor {
@Override
public boolean process(final Set extends TypeElement> annotations, final RoundEnvironment roundEnv) {
try {
ProcessorUtils.processingEnvironment = processingEnv;
ProcessorUtils.messageNote("Analyzing: " + getClass().getSimpleName());
roundEnv
.getElementsAnnotatedWith(ManyToOne.class)
.forEach(element -> {
ProcessorUtils.messageAnalyzing(getClass(), element);
ProcessorUtils.validFilterTenant(element);
validWhereLogicExclusionManyToOne(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 static void validWhereLogicExclusionManyToOne(Element element) {
final JArchExclusionLogic anotacaoFilter = element.getAnnotation(JArchExclusionLogic.class);
if (anotacaoFilter != null) {
ProcessorUtils.messageError("JARCH ERROR: Exclusão lógica não pode conter @ManyToOne, se for um mapeamento BI-DIRECIONAL remova esse mapeamento tornando UNI-DIRECIONAL ou transforme em exclusão física", element);
}
}
// @Override
// public Iterable extends Completion> getCompletions(Element element,
// AnnotationMirror annotation,
// ExecutableElement member,
// String userText) {
//
// return ProcessorUtils.getCompletionsFilterTenantLogicExclusion();
// }
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy