Search in sources :

Example 1 with HistoryAnnotationValidator

use of com.github.mvp4g.mvp4g2.processor.scanner.validation.HistoryAnnotationValidator in project mvp4g2 by mvp4g.

the class HistoryAnnotationScanner method scan.

public HistoryMetaModel scan(RoundEnvironment roundEnvironment) throws ProcessorException {
    // First we try to read an already created resource ...
    HistoryMetaModel model = this.restore();
    // Check if we have an element annotated with @Application
    if (!roundEnvironment.getElementsAnnotatedWith(History.class).isEmpty()) {
        // check annotation ...
        HistoryAnnotationValidator validator = HistoryAnnotationValidator.builder().roundEnvironment(roundEnvironment).processingEnvironment(this.processingEnvironment).build();
        // iterate over all history converters
        for (Element element : roundEnvironment.getElementsAnnotatedWith(History.class)) {
            // validate
            validator.validate(element);
            // process ...
            TypeElement typeElement = (TypeElement) element;
            History historyAnnotation = typeElement.getAnnotation(History.class);
            validator.validate(element);
            model.add(typeElement.getQualifiedName().toString(), historyAnnotation.type().toString());
        }
        // let's store the updated model
        this.processorUtils.store(model, this.createRelativeFileName());
    }
    return model;
}
Also used : HistoryMetaModel(com.github.mvp4g.mvp4g2.processor.model.HistoryMetaModel) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) HistoryAnnotationValidator(com.github.mvp4g.mvp4g2.processor.scanner.validation.HistoryAnnotationValidator) History(com.github.mvp4g.mvp4g2.core.history.annotation.History)

Aggregations

History (com.github.mvp4g.mvp4g2.core.history.annotation.History)1 HistoryMetaModel (com.github.mvp4g.mvp4g2.processor.model.HistoryMetaModel)1 HistoryAnnotationValidator (com.github.mvp4g.mvp4g2.processor.scanner.validation.HistoryAnnotationValidator)1 Element (javax.lang.model.element.Element)1 TypeElement (javax.lang.model.element.TypeElement)1