public class ElementUtils extends Object
| Constructor and Description |
|---|
ElementUtils() |
public static ExecutableElement findMethod(Class<?> type, String methodName)
public static ExecutableElement findMethod(DeclaredType type, String methodName)
public static String defaultValue(TypeMirror mirror)
public static TypeMirror getType(Class<?> element)
public static TypeElement getTypeElement(CharSequence typeName)
public static ExecutableElement findExecutableElement(DeclaredType type, String name)
public static ExecutableElement findExecutableElement(DeclaredType type, String name, int argumentCount)
public static VariableElement findVariableElement(DeclaredType type, String name)
public static boolean needsCastTo(TypeMirror sourceType, TypeMirror targetType)
public static String createReferenceName(ExecutableElement method)
public static TypeMirror boxType(ProcessorContext context, TypeMirror primitiveType)
public static DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs)
public static List<AnnotationMirror> collectAnnotations(AnnotationMirror markerAnnotation, String elementName, Element element, DeclaredType annotationClass)
public static TypeMirror getCommonSuperType(ProcessorContext context, Collection<TypeMirror> types)
public static String getReadableSignature(ExecutableElement method)
public static boolean hasError(TypeMirror mirror)
public static boolean isSubtypeBoxed(ProcessorContext context, TypeMirror from, TypeMirror to)
public static boolean isSubtype(TypeMirror type1, TypeMirror type2)
public static boolean isAssignable(TypeMirror from, TypeMirror to)
public static String getTypeId(TypeMirror mirror)
public static String getSimpleName(TypeElement element)
public static String getSimpleName(TypeMirror mirror)
public static String getDeclaredName(DeclaredType element, boolean includeTypeVariables)
public static String getClassQualifiedName(TypeElement e)
public static String getQualifiedName(TypeElement element)
public static String getQualifiedName(TypeMirror mirror)
public static boolean isNone(TypeMirror mirror)
public static boolean isVoid(TypeMirror mirror)
public static boolean isPrimitive(TypeMirror mirror)
public static boolean isFinal(TypeMirror mirror)
public static List<String> getQualifiedSuperTypeNames(TypeElement element)
public static List<TypeElement> getDeclaredTypes(TypeElement element)
public static Optional<TypeElement> findRootEnclosingType(Element element)
public static Optional<TypeElement> findParentEnclosingType(Element element)
public static Optional<TypeElement> findNearestEnclosingType(Element e)
public static List<TypeElement> getDirectSuperTypes(TypeElement element)
public static TypeElement getSuperType(TypeElement element)
public static boolean isDeprecated(TypeMirror baseType)
public static boolean isDeprecated(Element baseType)
public static boolean isPackageDeprecated(TypeElement baseType)
public static List<TypeElement> getSuperTypes(TypeElement element)
public static String getEnclosedQualifiedName(DeclaredType mirror)
public static String getPackageName(TypeMirror mirror)
public static TypeElement fromTypeMirror(TypeMirror mirror)
public static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String name)
ElementUtils.getAnnotationValue(javax.lang.model.element.AnnotationMirror, java.lang.String)
. The ElementUtils.getAnnotationValue does not work on Eclipse JDT compiler when an
annotation type is nested in a generic type, see issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=544940public static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String name, boolean resolveDefault)
ElementUtils.getAnnotationValue(javax.lang.model.element.AnnotationMirror, java.lang.String, boolean)
. The ElementUtils.getAnnotationValue does not work on Eclipse JDT compiler when an
annotation type is nested in a generic type, see issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=544940public static <T> List<T> getAnnotationValueList(Class<T> expectedListType, AnnotationMirror mirror, String name)
public static <T> T getAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name)
public static <T> T getAnnotationValue(Class<T> expectedType, AnnotationMirror mirror, String name, boolean resolveDefault)
public static <T> T resolveAnnotationValue(Class<T> expectedType, AnnotationValue value)
public static Object unboxAnnotationValue(AnnotationValue value)
public static AnnotationMirror findAnnotationMirror(Element element, Class<?> expectedAnnotationType)
public static AnnotationMirror findAnnotationMirror(List<? extends AnnotationMirror> mirrors, TypeMirror expectedAnnotationType)
public static AnnotationMirror findAnnotationMirror(Element element, TypeMirror annotationType)
public static PackageElement findPackageElement(Element e)
public static boolean isDeclaredMethodInSuperType(TypeElement element, String name, TypeMirror[] params)
public static List<ExecutableElement> getDeclaredMethodsInSuperTypes(TypeElement declaringElement, String name, TypeMirror... params)
declaringElement - the subtype element declaring the methodname - the name of the methodparams - the signature of the methodpublic static boolean isDefaultMethodOverridden(TypeElement declaringElement, String name, TypeMirror... params)
declaringElement or any of its direct super types override a
default interface method.
Any declaration of the given method and signature in the direct super type hierarchy - even if it is abstract - is considered to override the default method.
declaringElement - the type to checkname - the name of the default interface methodparams - the signature of the methodpublic static boolean typeEquals(TypeMirror type1, TypeMirror type2)
public static boolean areTypesCompatible(TypeMirror type1, TypeMirror type2)
public static List<String> getUniqueIdentifiers(List<TypeMirror> typeMirror)
public static String getUniqueIdentifier(TypeMirror typeMirror)
public static int compareByTypeHierarchy(TypeMirror t1, TypeMirror t2)
public static int compareByTypeHierarchy(TypeMirror t1, Set<String> t1SuperSet, TypeMirror t2, Set<String> t2SuperSet)
public static boolean canThrowTypeExact(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType)
public static boolean canThrowType(List<? extends TypeMirror> thrownTypes, TypeMirror exceptionType)
public static boolean isObject(TypeMirror actualType)
public static TypeMirror fillInGenericWildcards(TypeMirror type)
public static boolean hasGenericTypes(TypeMirror type)
public static TypeMirror eraseGenericTypes(TypeMirror type)
public static boolean variableEquals(VariableElement var1, VariableElement var2)
public static boolean signatureEquals(ExecutableElement e1, ExecutableElement e2)
public static boolean executableEquals(ExecutableElement e1, ExecutableElement e2)
public static List<TypeMirror> sortTypes(List<TypeMirror> list, boolean reverse)
public static int compareType(TypeMirror signature1, TypeMirror signature2)
public static List<TypeMirror> uniqueSortedTypes(Collection<TypeMirror> types, boolean reverse)
public static Collection<TypeMirror> uniqueTypes(Collection<TypeMirror> types)
public static int compareMethod(ExecutableElement method1, ExecutableElement method2)
public static List<AnnotationMirror> getRepeatedAnnotation(List<? extends AnnotationMirror> mirrors, DeclaredType base)
public static TypeElement castTypeElement(TypeMirror mirror)
public static String getBinaryName(TypeElement provider)