public class AnnotationHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_FIELD_NAME_RESNAME |
static String |
DEFAULT_FIELD_NAME_VALUE |
Constructor and Description |
---|
AnnotationHelper(ProcessingEnvironment processingEnv) |
Modifier and Type | Method and Description |
---|---|
String |
actionName(String annotationName) |
boolean |
defaultResIdValue(int[] values) |
boolean |
defaultResName(String[] resNames) |
List<? extends TypeMirror> |
directSupertypes(TypeMirror typeMirror) |
List<DeclaredType> |
extractAnnotationClassArrayParameter(Element element,
String annotationName,
String methodName) |
DeclaredType |
extractAnnotationClassParameter(Element element,
String annotationName) |
DeclaredType |
extractAnnotationClassParameter(Element element,
String annotationName,
String methodName) |
List<com.sun.codemodel.JFieldRef> |
extractAnnotationFieldRefs(ProcessHolder holder,
Element element,
String annotationName,
IRInnerClass rInnerClass,
boolean useElementName)
Returns a list of
JFieldRef linking to the R class, based on the
given annotation |
List<com.sun.codemodel.JFieldRef> |
extractAnnotationFieldRefs(ProcessHolder holder,
Element element,
String annotationName,
IRInnerClass rInnerClass,
boolean useElementName,
String idFieldName,
String resFieldName) |
<T> T |
extractAnnotationParameter(Element element,
String annotationName,
String methodName) |
int[] |
extractAnnotationResIdValueParameter(Element element,
String annotationName) |
int[] |
extractAnnotationResIdValueParameter(Element element,
String annotationName,
String fieldName) |
String[] |
extractAnnotationResNameParameter(Element element,
String annotationName) |
String[] |
extractAnnotationResNameParameter(Element element,
String annotationName,
String fieldName) |
List<String> |
extractAnnotationResources(Element element,
String annotationName,
IRInnerClass rInnerClass,
boolean useElementName)
Method to handle all annotations dealing with resource ids that can be
set using the value() parameter of the annotation (as int or int[]), the
resName() parameter of the annotation (as String or String[]), the
element name.
|
List<String> |
extractAnnotationResources(Element element,
String annotationName,
IRInnerClass rInnerClass,
boolean useElementName,
String idFieldName,
String resFieldName) |
String |
extractElementName(Element element,
String annotationName) |
AnnotationMirror |
findAnnotationMirror(Element annotatedElement,
String annotationName) |
String |
generatedClassQualifiedNameFromQualifiedName(String qualifiedName) |
Elements |
getElementUtils() |
Types |
getTypeUtils() |
boolean |
hasOneOfClassAnnotations(Element element,
Class<? extends Annotation> validAnnotation) |
boolean |
hasOneOfClassAnnotations(Element element,
List<Class<? extends Annotation>> validAnnotations) |
boolean |
isAbstract(Element element) |
boolean |
isAnnotation(TypeElement annotation,
String annotationName) |
boolean |
isFinal(Element element) |
boolean |
isInterface(TypeElement element) |
boolean |
isPrivate(Element element) |
boolean |
isPublic(Element element) |
boolean |
isSubtype(TypeElement t1,
TypeElement t2) |
boolean |
isSubtype(TypeMirror potentialSubtype,
TypeMirror potentialSupertype)
Tests whether one type is a subtype of another.
|
boolean |
isSynchronized(Element element) |
boolean |
isTopLevel(TypeElement element) |
void |
printAnnotationError(Element annotatedElement,
String annotationName,
String message) |
void |
printAnnotationMessage(Level level,
Element annotatedElement,
String annotationName,
String message) |
void |
printAnnotationWarning(Element annotatedElement,
String annotationName,
String message) |
void |
printError(Element element,
String message) |
TypeElement |
typeElementFromQualifiedName(String qualifiedName)
This method may return null if the
TypeElement cannot be found in
the processor classpath |
public static final String DEFAULT_FIELD_NAME_VALUE
public static final String DEFAULT_FIELD_NAME_RESNAME
public AnnotationHelper(ProcessingEnvironment processingEnv)
public boolean isSubtype(TypeMirror potentialSubtype, TypeMirror potentialSupertype)
public boolean isSubtype(TypeElement t1, TypeElement t2)
public List<? extends TypeMirror> directSupertypes(TypeMirror typeMirror)
public TypeElement typeElementFromQualifiedName(String qualifiedName)
TypeElement
cannot be found in
the processor classpathpublic String generatedClassQualifiedNameFromQualifiedName(String qualifiedName)
public AnnotationMirror findAnnotationMirror(Element annotatedElement, String annotationName)
public boolean isAnnotation(TypeElement annotation, String annotationName)
public void printAnnotationError(Element annotatedElement, String annotationName, String message)
public void printAnnotationWarning(Element annotatedElement, String annotationName, String message)
public void printAnnotationMessage(Level level, Element annotatedElement, String annotationName, String message)
public boolean isPrivate(Element element)
public boolean isPublic(Element element)
public boolean isAbstract(Element element)
public boolean isInterface(TypeElement element)
public boolean isTopLevel(TypeElement element)
public boolean isFinal(Element element)
public boolean isSynchronized(Element element)
public Elements getElementUtils()
public Types getTypeUtils()
public List<com.sun.codemodel.JFieldRef> extractAnnotationFieldRefs(ProcessHolder holder, Element element, String annotationName, IRInnerClass rInnerClass, boolean useElementName)
JFieldRef
linking to the R class, based on the
given annotationpublic List<com.sun.codemodel.JFieldRef> extractAnnotationFieldRefs(ProcessHolder holder, Element element, String annotationName, IRInnerClass rInnerClass, boolean useElementName, String idFieldName, String resFieldName)
public List<String> extractAnnotationResources(Element element, String annotationName, IRInnerClass rInnerClass, boolean useElementName)
element
- the annotated elementannotationName
- the annotation on the elementrInnerClass
- the R innerClass the resources belong touseElementName
- Should we use a default fallback strategy that uses the
element qualified name for a resource namepublic List<String> extractAnnotationResources(Element element, String annotationName, IRInnerClass rInnerClass, boolean useElementName, String idFieldName, String resFieldName)
public boolean defaultResName(String[] resNames)
public boolean defaultResIdValue(int[] values)
public String[] extractAnnotationResNameParameter(Element element, String annotationName)
public String[] extractAnnotationResNameParameter(Element element, String annotationName, String fieldName)
public int[] extractAnnotationResIdValueParameter(Element element, String annotationName)
public int[] extractAnnotationResIdValueParameter(Element element, String annotationName, String fieldName)
public <T> T extractAnnotationParameter(Element element, String annotationName, String methodName)
public List<DeclaredType> extractAnnotationClassArrayParameter(Element element, String annotationName, String methodName)
public DeclaredType extractAnnotationClassParameter(Element element, String annotationName, String methodName)
public DeclaredType extractAnnotationClassParameter(Element element, String annotationName)
public boolean hasOneOfClassAnnotations(Element element, Class<? extends Annotation> validAnnotation)
public boolean hasOneOfClassAnnotations(Element element, List<Class<? extends Annotation>> validAnnotations)
Copyright © 2010-2014. All Rights Reserved.