use of org.androidannotations.handler.GeneratingAnnotationHandler in project androidannotations by androidannotations.
the class ModelProcessor method generateElements.
@SuppressWarnings({ "unchecked", "rawtypes" })
private boolean generateElements(AnnotationElements validatedModel, ProcessHolder processHolder) throws Exception {
boolean isElementRemaining = false;
for (GeneratingAnnotationHandler generatingAnnotationHandler : environment.getGeneratingHandlers()) {
if (!generatingAnnotationHandler.isEnabled()) {
continue;
}
String annotationName = generatingAnnotationHandler.getTarget();
Set<? extends Element> annotatedElements = validatedModel.getRootAnnotatedElements(annotationName);
if (!annotatedElements.isEmpty()) {
LOGGER.debug("Processing root elements {}: {}", generatingAnnotationHandler.getClass().getSimpleName(), annotatedElements);
}
for (Element annotatedElement : annotatedElements) {
/*
* We do not generate code for abstract classes, because the
* generated classes are final anyway (we do not want anyone to
* extend them).
*/
if (!isAbstractClass(annotatedElement)) {
if (processHolder.getGeneratedClassHolder(annotatedElement) == null) {
TypeElement typeElement = (TypeElement) annotatedElement;
Element enclosingElement = annotatedElement.getEnclosingElement();
if (typeElement.getNestingKind() == NestingKind.MEMBER && processHolder.getGeneratedClassHolder(enclosingElement) == null) {
isElementRemaining = true;
} else {
GeneratedClassHolder generatedClassHolder = generatingAnnotationHandler.createGeneratedClassHolder(environment, typeElement);
processHolder.put(annotatedElement, generatedClassHolder);
generatingAnnotationHandler.process(annotatedElement, generatedClassHolder);
}
}
} else {
LOGGER.trace("Skip element {} because it's abstract", annotatedElement);
}
}
/*
* We currently do not take into account class annotations from
* ancestors. We should careful design the priority rules first.
*/
}
return isElementRemaining;
}
Aggregations