public final class Util extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
fillAllSuperTypes(Types types,
TypeMirror type,
List<TypeMirror> result)
Similar to
getAllSuperTypes(javax.lang.model.util.Types, javax.lang.model.type.TypeMirror) but avoids
instantiation of a new list. |
static TypeElement |
findTypeByBinaryName(Elements elements,
String binaryName)
Tries to find a type element using the provided Elements helper given its binary name.
|
static List<TypeMirror> |
getAllSuperClasses(Types types,
TypeMirror type)
Returns all the super classes of given type.
|
static List<TypeMirror> |
getAllSuperTypes(Types types,
TypeMirror type)
Similar to
getAllSuperClasses(javax.lang.model.util.Types, javax.lang.model.type.TypeMirror) but
returns all super types including implemented interfaces. |
static boolean |
isEqual(AnnotationValue oldVal,
AnnotationValue newVal) |
static boolean |
isSameType(TypeMirror t1,
TypeMirror t2)
To be used to compare types from different compilations (which are not comparable by standard means in Types).
|
static boolean |
isSubtype(TypeMirror type,
List<? extends TypeMirror> superTypes,
Types typeEnvironment)
Checks whether given type is a sub type or is equal to one of the provided types.
|
static Map<String,Map.Entry<? extends ExecutableElement,? extends AnnotationValue>> |
keyAnnotationAttributesByName(Map<? extends ExecutableElement,? extends AnnotationValue> attributes)
Extracts the names of the attributes from the executable elements that represents them in the given map and
returns a map keyed by those names.
|
static String |
toHumanReadableString(AnnotationValue v) |
static String |
toHumanReadableString(Element element) |
static String |
toHumanReadableString(TypeMirror t) |
static String |
toUniqueString(AnnotationValue v) |
static String |
toUniqueString(TypeMirror t)
Represents the type mirror as a string in such a way that it can be used for equality comparisons.
|
public static boolean isSameType(@Nonnull TypeMirror t1, @Nonnull TypeMirror t2)
t1 - first typet2 - second type@Nonnull public static String toUniqueString(@Nonnull TypeMirror t)
t - type to convert to string@Nonnull public static String toHumanReadableString(@Nonnull TypeMirror t)
@Nonnull public static String toUniqueString(@Nonnull AnnotationValue v)
@Nonnull public static String toHumanReadableString(@Nonnull AnnotationValue v)
@Nonnull public static List<TypeMirror> getAllSuperClasses(@Nonnull Types types, @Nonnull TypeMirror type)
types - the Types instance of the compilation environment from which the type comes fromtype - the type@Nonnull public static List<TypeMirror> getAllSuperTypes(@Nonnull Types types, @Nonnull TypeMirror type)
getAllSuperClasses(javax.lang.model.util.Types, javax.lang.model.type.TypeMirror) but
returns all super types including implemented interfaces.types - the Types instance of the compilation environment from which the type comes fromtype - the typepublic static void fillAllSuperTypes(@Nonnull Types types, @Nonnull TypeMirror type, @Nonnull List<TypeMirror> result)
getAllSuperTypes(javax.lang.model.util.Types, javax.lang.model.type.TypeMirror) but avoids
instantiation of a new list.types - the Types instance of the compilation environment from which the type comes fromtype - the typeresult - the list to add the results to.public static boolean isSubtype(@Nonnull TypeMirror type, @Nonnull List<? extends TypeMirror> superTypes, @Nonnull Types typeEnvironment)
type - the type to checksuperTypes - the list of supposed super typestypeEnvironment - the environment in which the type lives@Nonnull public static Map<String,Map.Entry<? extends ExecutableElement,? extends AnnotationValue>> keyAnnotationAttributesByName(@Nonnull Map<? extends ExecutableElement,? extends AnnotationValue> attributes)
attributes - the attributes as obtained by
AnnotationMirror.getElementValues()public static boolean isEqual(@Nonnull AnnotationValue oldVal, @Nonnull AnnotationValue newVal)
public static TypeElement findTypeByBinaryName(Elements elements, String binaryName)
elements - the elements instance to search the classpathbinaryName - the binary name of the classCopyright © 2014. All rights reserved.