public class AptUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
Elements |
elementUtils |
Filer |
filer |
Messager |
messager |
Types |
typeUtils |
| Constructor and Description |
|---|
AptUtils(Elements elementUtils,
Types typeUtils,
Messager messager,
Filer filer) |
| Modifier and Type | Method and Description |
|---|---|
static String |
annotationName(AnnotationMirror annotation) |
static boolean |
areSameByClass(AnnotationMirror am,
Class<? extends Annotation> anno)
Checks that the annotation
am has the name of anno. |
static boolean |
areSameByName(AnnotationMirror am,
String aname)
Checks that the annotation
am has the name aname. |
static TypeElement |
asTypeElement(TypeMirror typeMirror) |
static boolean |
containsAnnotation(AnnotationTree annotationTree,
Class<? extends Annotation> annotationClass) |
static boolean |
containsAnnotation(Set<Class<? extends Annotation>> annotationMirrors,
Class<? extends Annotation> annotationClass) |
static boolean |
containsElementsAnnotatedBy(Set<? extends TypeElement> typeElements,
Class<? extends Annotation> annotationClass) |
static long |
countElementsAnnotatedBy(Set<? extends TypeElement> typeElements,
Class<? extends Annotation> annotationClass) |
static TypeElement |
enclosingClass(Element elem)
Returns the innermost type element enclosing the given element
|
TypeMirror |
erasure(TypeElement typeElement) |
TypeMirror |
erasure(TypeMirror typeMirror) |
com.squareup.javapoet.TypeName |
extractTypeArgument(com.squareup.javapoet.TypeName typeName,
int argumentIndex) |
static Optional<info.archinnov.achilles.type.TypedMap> |
extractTypedMap(AnnotationTree annotationTree,
Class<? extends Annotation> annotationClass) |
static VariableElement |
findFieldInType(TypeElement type,
String name)
Returns the field of the class
|
ExecutableElement |
findGetter(TypeElement classElm,
VariableElement elm,
List<String> getterNames) |
ExecutableElement |
findSetter(TypeElement classElm,
VariableElement elm,
String setterName) |
<T extends Annotation> |
getAnnotationOnClass(TypeElement typeElement,
Class<T> annotationClass) |
<T extends Annotation> |
getAnnotationOnClass(TypeMirror typeMirror,
Class<T> annotationClass)
INSTANCE METHODS
|
static <T> T |
getElementValue(AnnotationMirror anno,
CharSequence name,
Class<T> expectedType,
boolean useDefaults)
Get the attribute with the name
name of the annotation
anno. |
static <T> List<T> |
getElementValueArray(AnnotationMirror anno,
CharSequence name,
Class<T> expectedType,
boolean useDefaults)
Get the attribute with the name
name of the annotation
anno, where the attribute has an array type. |
static <T> Optional<Class<T>> |
getElementValueClass(AnnotationMirror anno,
CharSequence name,
boolean useDefaults)
Get the Class that is referenced by attribute 'name'.
|
static Name |
getElementValueClassName(AnnotationMirror anno,
CharSequence name,
boolean useDefaults)
Get the Name of the class that is referenced by attribute 'name'.
|
static <T extends Enum<T>> |
getElementValueEnum(AnnotationMirror anno,
CharSequence name,
Class<T> t,
boolean useDefaults)
Version that is suitable for Enum elements.
|
static Map<ExecutableElement,AnnotationValue> |
getElementValuesWithDefaults(AnnotationMirror annotMirror)
Returns the values of an annotation's attributes, including defaults.
|
static List<? extends TypeMirror> |
getInterfaces(TypeMirror typeMirror) |
static String |
getShortname(com.squareup.javapoet.TypeName typeName) |
static List<? extends TypeMirror> |
getTypeArguments(TypeMirror typeMirror) |
static List<TypeElement> |
getTypesAnnotatedBy(Set<? extends TypeElement> annotatedTypes,
RoundEnvironment roundEnv,
Class<? extends Annotation> annotationClass) |
static java.util.stream.Stream<TypeElement> |
getTypesAnnotatedByAsStream(Set<? extends TypeElement> annotatedTypes,
RoundEnvironment roundEnv,
Class<? extends Annotation> annotationClass) |
static boolean |
isAnEnum(Object enumValue) |
static boolean |
isAnEnum(TypeMirror typeMirror) |
static boolean |
isAnnotationOfType(TypeElement element,
Class<? extends Annotation> annotationClass) |
static boolean |
isArray(TypeMirror typeMirror) |
boolean |
isAssignableFrom(Class<?> superClass,
TypeMirror typeMirror) |
boolean |
isCompositeTypeForCassandra(TypeMirror typeMirror) |
static boolean |
isEclipseCompiler(ExecutableElement executableElement) |
static boolean |
isEclipseCompiler(TypeElement typeElm) |
static boolean |
isEclipseCompiler(VariableElement varElm) |
static boolean |
isJavaCompiler(ExecutableElement executableElement) |
static boolean |
isJavaCompiler(TypeElement typeElm) |
static boolean |
isJavaCompiler(VariableElement varElm) |
static boolean |
isPrimitive(TypeMirror typeMirror) |
void |
print(Diagnostic.Kind kind,
String message,
Object... args) |
void |
printError(String message,
Object... args) |
void |
printMandatoryWarning(String message,
Object... args) |
void |
printNote(String message,
Object... args) |
void |
printWarning(String message,
Object... args) |
void |
validateFalse(boolean condition,
String message,
Object... params) |
void |
validateTrue(boolean condition,
String message,
Object... params) |
public final Elements elementUtils
public final Types typeUtils
public final Messager messager
public final Filer filer
public static boolean isPrimitive(TypeMirror typeMirror)
public static boolean isArray(TypeMirror typeMirror)
public static boolean isAnEnum(TypeMirror typeMirror)
public static boolean isAnEnum(Object enumValue)
public static List<? extends TypeMirror> getTypeArguments(TypeMirror typeMirror)
public static List<? extends TypeMirror> getInterfaces(TypeMirror typeMirror)
public static boolean containsAnnotation(Set<Class<? extends Annotation>> annotationMirrors, Class<? extends Annotation> annotationClass)
public static long countElementsAnnotatedBy(Set<? extends TypeElement> typeElements, Class<? extends Annotation> annotationClass)
public static boolean containsElementsAnnotatedBy(Set<? extends TypeElement> typeElements, Class<? extends Annotation> annotationClass)
public static boolean containsAnnotation(AnnotationTree annotationTree, Class<? extends Annotation> annotationClass)
public static List<TypeElement> getTypesAnnotatedBy(Set<? extends TypeElement> annotatedTypes, RoundEnvironment roundEnv, Class<? extends Annotation> annotationClass)
public static java.util.stream.Stream<TypeElement> getTypesAnnotatedByAsStream(Set<? extends TypeElement> annotatedTypes, RoundEnvironment roundEnv, Class<? extends Annotation> annotationClass)
public static Optional<info.archinnov.achilles.type.TypedMap> extractTypedMap(AnnotationTree annotationTree, Class<? extends Annotation> annotationClass)
public static TypeElement asTypeElement(TypeMirror typeMirror)
public static boolean isAnnotationOfType(TypeElement element, Class<? extends Annotation> annotationClass)
public static boolean areSameByClass(AnnotationMirror am, Class<? extends Annotation> anno)
am has the name of anno.
Values are ignored.public static boolean areSameByName(AnnotationMirror am, String aname)
am has the name aname. Values
are ignored.public static final String annotationName(AnnotationMirror annotation)
public static Map<ExecutableElement,AnnotationValue> getElementValuesWithDefaults(AnnotationMirror annotMirror)
annotMirror - annotation to examineAnnotationMirror.getElementValues(),
JavacElements.getElementValuesWithDefaults(AnnotationMirror)public static <T> T getElementValue(AnnotationMirror anno, CharSequence name, Class<T> expectedType, boolean useDefaults)
name of the annotation
anno. The result is expected to have type expectedType.
Note 1: The method does not work well for attributes of an array
type (as it would return a list of AnnotationValues). Use
getElementValueArray instead.
Note 2: The method does not work for attributes of an enum type,
as the AnnotationValue is a VarSymbol and would be cast to the enum type,
which doesn't work. Use getElementValueEnum instead.anno - the annotation to disassemblename - the name of the attribute to accessexpectedType - the expected type used to cast the return typeuseDefaults - whether to apply default values to the attribute.public static <T> List<T> getElementValueArray(AnnotationMirror anno, CharSequence name, Class<T> expectedType, boolean useDefaults)
name of the annotation
anno, where the attribute has an array type. One element of the
result is expected to have type expectedType.
Parameter useDefaults is used to determine whether default values
should be used for annotation values. Finding defaults requires
more computation, so should be false when no defaulting is needed.anno - the annotation to disassemblename - the name of the attribute to accessexpectedType - the expected type used to cast the return typeuseDefaults - whether to apply default values to the attribute.public static Name getElementValueClassName(AnnotationMirror anno, CharSequence name, boolean useDefaults)
public static <T> Optional<Class<T>> getElementValueClass(AnnotationMirror anno, CharSequence name, boolean useDefaults)
public static <T extends Enum<T>> T getElementValueEnum(AnnotationMirror anno, CharSequence name, Class<T> t, boolean useDefaults)
public static TypeElement enclosingClass(Element elem)
elem - the enclosed element of a classpublic static VariableElement findFieldInType(TypeElement type, String name)
public static boolean isJavaCompiler(VariableElement varElm)
public static boolean isJavaCompiler(TypeElement typeElm)
public static boolean isJavaCompiler(ExecutableElement executableElement)
public static boolean isEclipseCompiler(VariableElement varElm)
public static boolean isEclipseCompiler(TypeElement typeElm)
public static boolean isEclipseCompiler(ExecutableElement executableElement)
public static String getShortname(com.squareup.javapoet.TypeName typeName)
public <T extends Annotation> Optional<T> getAnnotationOnClass(TypeMirror typeMirror, Class<T> annotationClass)
public <T extends Annotation> Optional<T> getAnnotationOnClass(TypeElement typeElement, Class<T> annotationClass)
public com.squareup.javapoet.TypeName extractTypeArgument(com.squareup.javapoet.TypeName typeName,
int argumentIndex)
public boolean isAssignableFrom(Class<?> superClass, TypeMirror typeMirror)
public ExecutableElement findGetter(TypeElement classElm, VariableElement elm, List<String> getterNames)
public ExecutableElement findSetter(TypeElement classElm, VariableElement elm, String setterName)
public void print(Diagnostic.Kind kind, String message, Object... args)
public TypeMirror erasure(TypeElement typeElement)
public TypeMirror erasure(TypeMirror typeMirror)
public boolean isCompositeTypeForCassandra(TypeMirror typeMirror)
Copyright © 2012-2021. All Rights Reserved.