com.googlecode.androidannotations.helper
Class AnnotationHelper

java.lang.Object
  extended by com.googlecode.androidannotations.helper.AnnotationHelper
Direct Known Subclasses:
EActivityProcessor, EApplicationProcessor, EBeanProcessor, EProviderProcessor, EReceiverProcessor, EServiceProcessor, EViewGroupProcessor, EViewProcessor, ProjectRClassFinder, SharedPrefProcessor, TargetAnnotationHelper

public class AnnotationHelper
extends java.lang.Object


Field Summary
protected  javax.annotation.processing.ProcessingEnvironment processingEnv
           
 
Constructor Summary
AnnotationHelper(javax.annotation.processing.ProcessingEnvironment processingEnv)
           
 
Method Summary
 javax.lang.model.element.AnnotationMirror findAnnotationMirror(javax.lang.model.element.Element annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
           
 javax.lang.model.util.Elements getElementUtils()
           
 javax.lang.model.util.Types getTypeUtils()
           
 boolean isAbstract(javax.lang.model.element.Element element)
           
 boolean isAnnotation(javax.lang.model.element.TypeElement annotation, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
           
 boolean isFinal(javax.lang.model.element.Element element)
           
 boolean isInterface(javax.lang.model.element.TypeElement element)
           
 boolean isPrivate(javax.lang.model.element.Element element)
           
 boolean isSubtype(javax.lang.model.element.TypeElement t1, javax.lang.model.element.TypeElement t2)
           
 boolean isSubtype(javax.lang.model.type.TypeMirror potentialSubtype, javax.lang.model.type.TypeMirror potentialSupertype)
          Tests whether one type is a subtype of another.
 boolean isSynchronized(javax.lang.model.element.Element element)
           
 void printAnnotationError(javax.lang.model.element.Element annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.String message)
           
 void printAnnotationMessage(javax.tools.Diagnostic.Kind diagnosticKind, javax.lang.model.element.Element annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.String message)
           
 void printAnnotationWarning(javax.lang.model.element.Element annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.String message)
           
 void printError(javax.lang.model.element.Element element, java.lang.String message)
           
 javax.lang.model.element.TypeElement typeElementFromQualifiedName(java.lang.String qualifiedName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

processingEnv

protected final javax.annotation.processing.ProcessingEnvironment processingEnv
Constructor Detail

AnnotationHelper

public AnnotationHelper(javax.annotation.processing.ProcessingEnvironment processingEnv)
Method Detail

isSubtype

public boolean isSubtype(javax.lang.model.type.TypeMirror potentialSubtype,
                         javax.lang.model.type.TypeMirror potentialSupertype)
Tests whether one type is a subtype of another. Any type is considered to be a subtype of itself. This method adds additional behavior : if Types.isSubtype(TypeMirror, TypeMirror) returns false, and the inheritance chain of potentialSubtype contains an ErrorType that ends with a "_" at the end of its name, we return true. That's because when the code is cleaned and regenerated all at once, the "_" don't exist any more. Our assumption is that it can't do much harm in those cases. A better implementation would be to take advantage of the multiple rounds of annotation processing, and do those checks in later rounds.

Parameters:
potentialSubtype - the first type
potentialSupertype - the second type
Returns:
true if and only if the first type is a subtype of the second
Throws:
java.lang.IllegalArgumentException - if given an executable or package type
See Also:
Types.isSubtype(TypeMirror, TypeMirror)

isSubtype

public boolean isSubtype(javax.lang.model.element.TypeElement t1,
                         javax.lang.model.element.TypeElement t2)

typeElementFromQualifiedName

public javax.lang.model.element.TypeElement typeElementFromQualifiedName(java.lang.String qualifiedName)

findAnnotationMirror

public javax.lang.model.element.AnnotationMirror findAnnotationMirror(javax.lang.model.element.Element annotatedElement,
                                                                      java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)

isAnnotation

public boolean isAnnotation(javax.lang.model.element.TypeElement annotation,
                            java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)

printAnnotationError

public void printAnnotationError(javax.lang.model.element.Element annotatedElement,
                                 java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
                                 java.lang.String message)

printAnnotationWarning

public void printAnnotationWarning(javax.lang.model.element.Element annotatedElement,
                                   java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
                                   java.lang.String message)

printAnnotationMessage

public void printAnnotationMessage(javax.tools.Diagnostic.Kind diagnosticKind,
                                   javax.lang.model.element.Element annotatedElement,
                                   java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
                                   java.lang.String message)

printError

public void printError(javax.lang.model.element.Element element,
                       java.lang.String message)

isPrivate

public boolean isPrivate(javax.lang.model.element.Element element)

isAbstract

public boolean isAbstract(javax.lang.model.element.Element element)

isInterface

public boolean isInterface(javax.lang.model.element.TypeElement element)

isFinal

public boolean isFinal(javax.lang.model.element.Element element)

isSynchronized

public boolean isSynchronized(javax.lang.model.element.Element element)

getElementUtils

public javax.lang.model.util.Elements getElementUtils()

getTypeUtils

public javax.lang.model.util.Types getTypeUtils()


Copyright © 2010-2012. All Rights Reserved.