Search in sources :

Example 1 with AnnotationHandler

use of org.androidannotations.handler.AnnotationHandler in project androidannotations by androidannotations.

the class RoboGuicePlugin method getHandlers.

@Override
public List<AnnotationHandler<?>> getHandlers(AndroidAnnotationsEnvironment androidAnnotationEnv) {
    List<AnnotationHandler<?>> annotationHandlers = new ArrayList<>();
    annotationHandlers.add(new RoboGuiceHandler(androidAnnotationEnv));
    return annotationHandlers;
}
Also used : ArrayList(java.util.ArrayList) RoboGuiceHandler(org.androidannotations.roboguice.handler.RoboGuiceHandler) AnnotationHandler(org.androidannotations.handler.AnnotationHandler)

Example 2 with AnnotationHandler

use of org.androidannotations.handler.AnnotationHandler in project androidannotations by androidannotations.

the class OrmLitePlugin method getHandlers.

@Override
public List<AnnotationHandler<?>> getHandlers(AndroidAnnotationsEnvironment androidAnnotationEnv) {
    List<AnnotationHandler<?>> annotationHandlers = new ArrayList<>();
    annotationHandlers.add(new OrmLiteDaoHandler(androidAnnotationEnv));
    return annotationHandlers;
}
Also used : OrmLiteDaoHandler(org.androidannotations.ormlite.handler.OrmLiteDaoHandler) ArrayList(java.util.ArrayList) AnnotationHandler(org.androidannotations.handler.AnnotationHandler)

Example 3 with AnnotationHandler

use of org.androidannotations.handler.AnnotationHandler in project androidannotations by androidannotations.

the class AnnotationHandlers method getSupportedAnnotationTypes.

public Set<String> getSupportedAnnotationTypes() {
    if (supportedAnnotationNames == null) {
        Set<String> annotationNames = new HashSet<>();
        for (AnnotationHandler annotationHandler : annotationHandlers) {
            annotationNames.add(annotationHandler.getTarget());
        }
        supportedAnnotationNames = Collections.unmodifiableSet(annotationNames);
    }
    return supportedAnnotationNames;
}
Also used : AnnotationHandler(org.androidannotations.handler.AnnotationHandler) GeneratingAnnotationHandler(org.androidannotations.handler.GeneratingAnnotationHandler) HashSet(java.util.HashSet)

Example 4 with AnnotationHandler

use of org.androidannotations.handler.AnnotationHandler in project androidannotations by androidannotations.

the class RestSpringPlugin method getHandlers.

@Override
public List<AnnotationHandler<?>> getHandlers(AndroidAnnotationsEnvironment androidAnnotationEnv) {
    List<AnnotationHandler<?>> annotationHandlers = new ArrayList<>();
    annotationHandlers.add(new RestHandler(androidAnnotationEnv));
    annotationHandlers.add(new FieldHandler(androidAnnotationEnv));
    annotationHandlers.add(new PartHandler(androidAnnotationEnv));
    annotationHandlers.add(new BodyHandler(androidAnnotationEnv));
    annotationHandlers.add(new GetHandler(androidAnnotationEnv));
    annotationHandlers.add(new PostHandler(androidAnnotationEnv));
    annotationHandlers.add(new PutHandler(androidAnnotationEnv));
    annotationHandlers.add(new PatchHandler(androidAnnotationEnv));
    annotationHandlers.add(new DeleteHandler(androidAnnotationEnv));
    annotationHandlers.add(new HeadHandler(androidAnnotationEnv));
    annotationHandlers.add(new OptionsHandler(androidAnnotationEnv));
    annotationHandlers.add(new PathHandler(androidAnnotationEnv));
    annotationHandlers.add(new HeaderHandler(androidAnnotationEnv));
    annotationHandlers.add(new HeadersHandler(androidAnnotationEnv));
    annotationHandlers.add(new RestServiceHandler(androidAnnotationEnv));
    return annotationHandlers;
}
Also used : FieldHandler(org.androidannotations.rest.spring.handler.FieldHandler) PatchHandler(org.androidannotations.rest.spring.handler.PatchHandler) PartHandler(org.androidannotations.rest.spring.handler.PartHandler) ArrayList(java.util.ArrayList) PathHandler(org.androidannotations.rest.spring.handler.PathHandler) DeleteHandler(org.androidannotations.rest.spring.handler.DeleteHandler) RestServiceHandler(org.androidannotations.rest.spring.handler.RestServiceHandler) HeaderHandler(org.androidannotations.rest.spring.handler.HeaderHandler) PostHandler(org.androidannotations.rest.spring.handler.PostHandler) HeadersHandler(org.androidannotations.rest.spring.handler.HeadersHandler) RestHandler(org.androidannotations.rest.spring.handler.RestHandler) BodyHandler(org.androidannotations.rest.spring.handler.BodyHandler) OptionsHandler(org.androidannotations.rest.spring.handler.OptionsHandler) HeadHandler(org.androidannotations.rest.spring.handler.HeadHandler) AnnotationHandler(org.androidannotations.handler.AnnotationHandler) PutHandler(org.androidannotations.rest.spring.handler.PutHandler) GetHandler(org.androidannotations.rest.spring.handler.GetHandler)

Example 5 with AnnotationHandler

use of org.androidannotations.handler.AnnotationHandler in project androidannotations by androidannotations.

the class ModelProcessor method process.

@SuppressWarnings({ "unchecked", "rawtypes" })
public ProcessResult process(AnnotationElements validatedModel) throws Exception {
    ProcessHolder processHolder = new ProcessHolder(environment.getProcessingEnvironment());
    environment.setProcessHolder(processHolder);
    LOGGER.info("Processing root elements");
    /*
		 * We generate top classes then inner classes, then inner classes of
		 * inner classes, etc... until there is no more classes to generate.
		 */
    while (generateElements(validatedModel, processHolder)) {
        // CHECKSTYLE:OFF
        ;
    // CHECKSTYLE:ON
    }
    LOGGER.info("Processing enclosed elements");
    for (AnnotationHandler annotationHandler : environment.getDecoratingHandlers()) {
        if (!annotationHandler.isEnabled()) {
            continue;
        }
        String annotationName = annotationHandler.getTarget();
        /*
			 * For ancestors, the annotationHandler manipulates the annotated
			 * elements, but uses the holder for the root element
			 */
        Set<AnnotatedAndRootElements> ancestorAnnotatedElements = validatedModel.getAncestorAnnotatedElements(annotationName);
        if (!ancestorAnnotatedElements.isEmpty()) {
            LOGGER.debug("Processing enclosed elements with {}: {}", annotationHandler.getClass().getSimpleName(), ancestorAnnotatedElements);
        }
        for (AnnotatedAndRootElements elements : ancestorAnnotatedElements) {
            GeneratedClassHolder holder = processHolder.getGeneratedClassHolder(elements.rootTypeElement);
            /*
				 * Annotations coming from ancestors may be applied to root
				 * elements that are not validated, and therefore not available.
				 */
            if (holder != null) {
                processThrowing(annotationHandler, elements.annotatedElement, holder);
            }
        }
        Set<? extends Element> rootAnnotatedElements = validatedModel.getRootAnnotatedElements(annotationName);
        for (Element annotatedElement : rootAnnotatedElements) {
            Element enclosingElement;
            if (annotatedElement instanceof TypeElement) {
                enclosingElement = annotatedElement;
            } else {
                enclosingElement = annotatedElement.getEnclosingElement();
                /*
					 * we are processing a method parameter
					 */
                if (enclosingElement instanceof ExecutableElement) {
                    enclosingElement = enclosingElement.getEnclosingElement();
                }
            }
            /*
				 * We do not generate code for elements belonging to abstract
				 * classes, because the generated classes are final anyway
				 */
            if (!isAbstractClass(enclosingElement)) {
                GeneratedClassHolder holder = processHolder.getGeneratedClassHolder(enclosingElement);
                /*
					 * The holder can be null if the annotated holder class is
					 * already invalidated.
					 */
                if (holder != null) {
                    processThrowing(annotationHandler, annotatedElement, holder);
                }
            } else {
                LOGGER.trace("Skip element {} because enclosing element {} is abstract", annotatedElement, enclosingElement);
            }
        }
    }
    return new //
    ProcessResult(//
    processHolder.codeModel(), processHolder.getOriginatingElements());
}
Also used : GeneratedClassHolder(org.androidannotations.holder.GeneratedClassHolder) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) ExecutableElement(javax.lang.model.element.ExecutableElement) AnnotationHandler(org.androidannotations.handler.AnnotationHandler) GeneratingAnnotationHandler(org.androidannotations.handler.GeneratingAnnotationHandler) AnnotatedAndRootElements(org.androidannotations.internal.model.AnnotationElements.AnnotatedAndRootElements)

Aggregations

AnnotationHandler (org.androidannotations.handler.AnnotationHandler)8 ArrayList (java.util.ArrayList)6 Element (javax.lang.model.element.Element)2 GeneratingAnnotationHandler (org.androidannotations.handler.GeneratingAnnotationHandler)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 ElementValidation (org.androidannotations.ElementValidation)1 GeneratedClassHolder (org.androidannotations.holder.GeneratedClassHolder)1 AfterExtrasHandler (org.androidannotations.internal.core.handler.AfterExtrasHandler)1 AfterInjectHandler (org.androidannotations.internal.core.handler.AfterInjectHandler)1 AfterPreferencesHandler (org.androidannotations.internal.core.handler.AfterPreferencesHandler)1 AfterTextChangeHandler (org.androidannotations.internal.core.handler.AfterTextChangeHandler)1 AfterViewsHandler (org.androidannotations.internal.core.handler.AfterViewsHandler)1 AnimationResHandler (org.androidannotations.internal.core.handler.AnimationResHandler)1 AppHandler (org.androidannotations.internal.core.handler.AppHandler)1 BackgroundHandler (org.androidannotations.internal.core.handler.BackgroundHandler)1 BeanHandler (org.androidannotations.internal.core.handler.BeanHandler)1