@Utility public class ProcessingUtility extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ProcessingUtility.AnnotationValueVisitor
Important: Do not call
AbstractAnnotationValueVisitor6.visit(javax.lang.model.element.AnnotationValue) as this passes null as the visitor-specified parameter instead of a type importer. |
static class |
ProcessingUtility.QualifiedNameTypeVisitor
This type visitor returns the qualified name of the given type without generic parameters.
|
static class |
ProcessingUtility.SimpleNameTypeVisitor
This type visitor returns the simple name of the given type without generic parameters.
|
| Constructor and Description |
|---|
ProcessingUtility() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
correspond(@Nonnull Element element,
@Nonnull Class<?> type)
Returns whether the type of the given element corresponds to the given type.
|
static boolean |
correspond(@Nonnull TypeMirror mirror,
@Nonnull Class<?> type)
Returns whether the given mirror corresponds to the given type.
|
static <E extends Element> |
filter(@Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<Element> elements,
@Nonnull ElementKind kind,
@Nonnull Class<E> type)
Returns the elements in the given iterable which are of the given kind cast to the given type.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<VariableElement> |
getAllFields(@Nonnull TypeElement typeElement)
Returns the directly declared and inherited fields of the given type element.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<Element> |
getAllMembers(@Nonnull TypeElement typeElement)
Returns the directly declared and inherited members of the given type element.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<ExecutableElement> |
getAllMethods(@Nonnull TypeElement typeElement)
Returns the directly declared and inherited methods of the given type element.
|
static @Nonnull String |
getAnnotationAsString(@Nonnull AnnotationMirror annotationMirror,
@Nonnull TypeImporter typeImporter)
Returns the given annotation with its values as a string.
|
static @Nullable AnnotationMirror |
getAnnotationMirror(@Nonnull Element element,
@Nonnull Class<? extends Annotation> annotationType)
Returns the annotation mirror corresponding to the given annotation type of the given element or null if not found.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<AnnotationMirror> |
getAnnotationMirrors(@Nonnull Element element)
Returns the annotation mirrors that are present on the given element or its (return) (component) type.
|
static @Nonnull String |
getAnnotationsAsString(@Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<? extends AnnotationMirror> annotationMirrors,
@Nonnull TypeImporter typeImporter)
Returns the given annotations with their values as a string.
|
static @Nonnull String |
getAnnotationsAsString(@Nonnull TypeMirror typeMirror,
@Nonnull TypeImporter typeImporter)
Returns the annotations of the given type mirror with their values as a string.
|
static @Nullable AnnotationValue |
getAnnotationValue(@Nonnull AnnotationMirror annotationMirror)
Returns the annotation value for the value method of the given annotation mirror or null if not found.
|
static @Nullable AnnotationValue |
getAnnotationValue(@Nonnull AnnotationMirror annotationMirror,
@Nonnull String methodName)
Returns the annotation value for the given method name of the given annotation mirror or null if not found.
|
static @Nullable AnnotationValue |
getAnnotationValue(@Nonnull Element element,
@Nonnull Class<? extends Annotation> annotationType)
Returns the annotation value for the default value method of the given annotation type on the given element or null if not found.
|
static @Nullable AnnotationValue |
getAnnotationValue(@Nonnull Element element,
@Nonnull Class<? extends Annotation> annotationType,
@Nonnull String methodName)
Returns the annotation value for the given method name of the given annotation type on the given element or null if not found.
|
static @Nonnull String |
getAnnotationValueAsString(@Nonnull AnnotationValue annotationValue,
@Nonnull TypeImporter typeImporter)
Returns the given annotation value as a string.
|
static @Nonnull Map<String,AnnotationValue> |
getAnnotationValues(@Nonnull AnnotationMirror annotationMirror)
Returns the annotation values mapped from their name for all methods of the given annotation mirror.
|
static @Nonnull TypeMirror |
getBoxedType(@Nonnull TypeMirror typeMirror)
Returns the boxed type of the given type mirror or its component type in case of arrays.
|
static @Nullable Class<?> |
getClass(@Nullable AnnotationValue annotationValue)
Returns the given annotation value as a class object or propagates null.
|
static @Nullable Class<?> |
getClass(@Nonnull TypeMirror typeMirror)
Returns the given type mirror as a class object.
|
static @Nullable TypeMirror |
getComponentType(@Nonnull Element element)
Returns the component type of the type of the given element if it is an array or an iterable.
|
static @Nullable TypeMirror |
getComponentType(@Nonnull Element element,
@Nonnull ErrorLogger errorLogger)
Returns the component type of the type of the given element if it is an array or an iterable and logs errors with the given logger otherwise.
|
static @Nullable TypeMirror |
getComponentType(@Nonnull TypeMirror type)
Returns the component type of the given type if it is an array or an iterable.
|
static @Nullable TypeMirror |
getComponentType(@Nonnull TypeMirror type,
@Nonnull ErrorLogger errorLogger)
Returns the component type of the given type if it is an array or an iterable and logs errors with the given logger otherwise.
|
static @Nullable List<TypeMirror> |
getComponentTypes(@Nonnull Element element)
Returns the component types of the type of the given element if it is an array or an iterable.
|
static @Nullable List<TypeMirror> |
getComponentTypes(@Nonnull Element element,
@Nonnull ErrorLogger errorLogger)
Returns the component types of the type of the given element if it is an array or an iterable and logs errors with the given logger otherwise.
|
static @Nullable List<TypeMirror> |
getComponentTypes(@Nonnull TypeMirror type)
Returns the component types of the given type if it is an array or an iterable.
|
static @Nullable List<TypeMirror> |
getComponentTypes(@Nonnull TypeMirror type,
@Nonnull ErrorLogger errorLogger)
Returns the component types of the given type if it is an array or an iterable and logs errors with the given logger otherwise.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<ExecutableElement> |
getConstructors(@Nonnull TypeElement typeElement)
Returns the directly declared constructors of the given type element.
|
static <T extends Enum<T>> |
getEnum(@Nullable AnnotationValue annotationValue,
@Nonnull @EnumType Class<T> type)
Returns the given annotation value as a constant of the given enum type or propagates null.
|
static <T extends Enum<T>> |
getEnums(@Nullable AnnotationValue annotationValue,
@Nonnull @EnumType Class<T> type)
Returns the given annotation value as constants of the given enum type or returns an empty iterable if the given annotation value is null.
|
static @Nullable TypeMirror |
getErasedTypeMirror(@Nonnull Class<?> type)
Returns the given class object as an erased type mirror.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<VariableElement> |
getFields(@Nonnull TypeElement typeElement)
Returns the directly declared fields of the given type element.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<VariableElement> |
getFieldsOfType(@Nonnull TypeElement typeElement,
@Nonnull Class<?> fieldType)
Returns a list of all the fields with the given type in the given type element.
|
static @Nullable VariableElement |
getFirstPublicStaticFieldOfType(@Nonnull TypeElement typeElement,
@Nonnull Class<?> fieldType)
Returns the first public and static field with the given type in the given type element.
|
static <T> T |
getInstance(@Nullable AnnotationValue annotationValue,
@Nonnull Class<T> desiredType)
Returns the given annotation value as a new instance of the given type or propagates null.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<Element> |
getMembers(@Nonnull TypeElement typeElement)
Returns the directly declared members of the given type element.
|
static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<ExecutableElement> |
getMethods(@Nonnull TypeElement typeElement)
Returns the directly declared methods of the given type element.
|
static @Nullable ExecutableElement |
getNonPrivateMethod(@Nonnull TypeElement typeElement,
@Nonnull String methodName,
@Nonnull Class<?> returnType,
Class<?>... parameterTypes)
Returns the non-private method with the given name, return type, parameter types and no thrown types in the given type element or null if no such method is found.
|
static @Nonnull String |
getQualifiedName(@Nonnull AnnotationMirror annotationMirror)
Returns the qualified name of the annotation type of the given annotation mirror.
|
static @Nonnull String |
getQualifiedName(@Nonnull TypeMirror typeMirror)
Returns the qualified name of the given type mirror without generic parameters.
|
static @Nonnull String |
getQualifiedPackageName(@Nonnull Element element)
Returns the qualified name of the package in which the given element is declared.
|
static @Nonnull String |
getSimpleName(@Nonnull AnnotationMirror annotationMirror)
Returns the simple name of the given annotation mirror.
|
static @Nonnull String |
getSimpleName(@Nonnull TypeMirror typeMirror)
Returns the simple name of the given type mirror without generic parameters.
|
static @Nonnull String |
getSimpleNameWithLeadingAt(@Nonnull AnnotationMirror annotationMirror)
Returns the simple name of the given annotation mirror with a leading at symbol.
|
static @Nullable String |
getString(@Nullable AnnotationValue annotationValue)
Returns the given annotation value as a string or propagates null.
|
static @Nullable DeclaredType |
getSupertype(@Nonnull DeclaredType sourceType,
@Nonnull Class<?> targetType)
Returns the supertype of the given source type that corresponds to the given target type or null (without logged errors) if not found.
|
static @Nonnull TypeElement |
getSurroundingType(@Nonnull Element element)
Returns the type in which the given element is declared.
|
static @Nonnull TypeMirror |
getType(@Nonnull Element element)
Returns the type of the given element or the return type if the given element is an executable element.
|
static @Nonnull TypeMirror |
getType(@Nonnull TypeMirror type)
Returns the given type or the return type if the given type is an executable type.
|
static @Nullable TypeElement |
getTypeElement(@Nonnull TypeMirror typeMirror)
Returns the given type mirror or its component type in case of arrays as a type element.
|
static @Nullable TypeMirror |
getTypeMirror(@Nonnull Class<?> type)
Returns the given class object as a type mirror.
|
static boolean |
hasAnnotation(@Nonnull Element element,
@Nonnull Class<? extends Annotation> annotationType)
Returns whether the given element has an annotation of the given type.
|
static boolean |
hasNonPrivateMethod(@Nonnull TypeElement typeElement,
@Nonnull String methodName,
@Nonnull Class<?> returnType,
Class<?>... parameterTypes)
Returns whether the given type element contains a non-private method with the given name, return type, parameter types and no thrown types.
|
static boolean |
hasPublicDefaultConstructor(@Nonnull TypeElement typeElement)
Returns whether the given type element has a public default constructor.
|
static boolean |
isDeclaredInDigitalIDLibrary(@Nonnull Element element)
Returns whether the given element is declared in the Digital ID library (DID SDK).
|
static boolean |
isDeclaredInRuntimeEnvironment(@Nonnull Element element)
Returns whether the given element is declared in the Java Runtime Environment (JRE).
|
static boolean |
isGetter(@Nonnull ExecutableElement method)
Returns whether the given method is a (potentially static) getter.
|
static boolean |
isPrimitive(@Nonnull TypeMirror typeMirror)
Returns whether the given type mirror or its component type in case of arrays is primitive.
|
static boolean |
isRawlyAssignable(@Nonnull Element element,
@Nonnull Class<?> type)
Returns whether the given element is rawly assignable to the given type.
|
static boolean |
isRawlyAssignable(@Nonnull TypeMirror declaredType,
@Nonnull Class<?> desiredType)
Returns whether the given declared type is rawly assignable to the given desired type.
|
static boolean |
isRawSubtype(@Nonnull Element element,
@Nonnull Class<?> type)
Returns whether the type of the given element is a raw subtype of the given type.
|
static boolean |
isRawSubtype(@Nonnull TypeMirror declaredType,
@Nonnull Class<?> desiredType)
Returns whether the given declared type is a raw subtype of the given desired type.
|
boolean |
isSetter(@Nonnull ExecutableElement method)
Returns whether the given method is a (potentially static) setter.
|
@Pure @Nonnull public static @Nonnull String getQualifiedPackageName(@Nonnull @Nonnull Element element)
@Pure public static boolean isDeclaredInRuntimeEnvironment(@Nonnull @Nonnull Element element)
@Pure
@TODO(task="Change the prefix back to \'net.digitalid.\'.",
date="2016-11-08",
author=KASPAR_ETTER)
public static boolean isDeclaredInDigitalIDLibrary(@Nonnull
@Nonnull Element element)
@Pure @Nonnull public static @Nonnull TypeElement getSurroundingType(@Nonnull @Nonnull Element element)
element.getKind() != ElementKind.PACKAGE - the element may not be a package.@Pure @Nonnull public static <E extends Element> @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<E> filter(@Nonnull @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<Element> elements, @Nonnull @Nonnull ElementKind kind, @Nonnull @Nonnull Class<E> type)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<Element> getMembers(@Nonnull @Nonnull TypeElement typeElement)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<VariableElement> getFields(@Nonnull @Nonnull TypeElement typeElement)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<ExecutableElement> getMethods(@Nonnull @Nonnull TypeElement typeElement)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<ExecutableElement> getConstructors(@Nonnull @Nonnull TypeElement typeElement)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<Element> getAllMembers(@Nonnull @Nonnull TypeElement typeElement)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<VariableElement> getAllFields(@Nonnull @Nonnull TypeElement typeElement)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<ExecutableElement> getAllMethods(@Nonnull @Nonnull TypeElement typeElement)
@Pure @Nonnull public static @Nonnull TypeMirror getType(@Nonnull @Nonnull TypeMirror type)
@Pure @Nonnull public static @Nonnull TypeMirror getType(@Nonnull @Nonnull Element element)
@Pure @Nonnull public static @Nonnull String getSimpleName(@Nonnull @Nonnull AnnotationMirror annotationMirror)
@Pure @Nonnull public static @Nonnull String getSimpleNameWithLeadingAt(@Nonnull @Nonnull AnnotationMirror annotationMirror)
@Pure @Nonnull public static @Nonnull String getQualifiedName(@Nonnull @Nonnull AnnotationMirror annotationMirror)
@Pure
@TODO(task="Figure out whether and where we still need to collect the annotation mirrors of the element type and the component type in case of arrays. (This was probably necessary when we restricted annotations to \'ElementType.TYPE_USE\'.)",
date="2017-01-26",
author=KASPAR_ETTER)
@Nonnull
public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<AnnotationMirror> getAnnotationMirrors(@Nonnull
@Nonnull Element element)
@Pure @Nullable public static @Nullable AnnotationMirror getAnnotationMirror(@Nonnull @Nonnull Element element, @Nonnull @Nonnull Class<? extends Annotation> annotationType)
@Pure public static boolean hasAnnotation(@Nonnull @Nonnull Element element, @Nonnull @Nonnull Class<? extends Annotation> annotationType)
@Pure @Nonnull public static @Nonnull Map<String,AnnotationValue> getAnnotationValues(@Nonnull @Nonnull AnnotationMirror annotationMirror)
@Pure @Nullable public static @Nullable AnnotationValue getAnnotationValue(@Nonnull @Nonnull AnnotationMirror annotationMirror, @Nonnull @Nonnull String methodName)
@Pure @Nullable public static @Nullable AnnotationValue getAnnotationValue(@Nonnull @Nonnull AnnotationMirror annotationMirror)
@Pure @Nullable public static @Nullable AnnotationValue getAnnotationValue(@Nonnull @Nonnull Element element, @Nonnull @Nonnull Class<? extends Annotation> annotationType, @Nonnull @Nonnull String methodName)
@Pure @Nullable public static @Nullable AnnotationValue getAnnotationValue(@Nonnull @Nonnull Element element, @Nonnull @Nonnull Class<? extends Annotation> annotationType)
@Pure @Nullable public static @Nullable String getString(@Nullable @Nullable AnnotationValue annotationValue)
@Pure @Nullable public static <T extends Enum<T>> T getEnum(@Nullable @Nullable AnnotationValue annotationValue, @Nonnull @EnumType @Nonnull @EnumType Class<T> type)
@Pure @Nonnull public static <T extends Enum<T>> @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<T> getEnums(@Nullable @Nullable AnnotationValue annotationValue, @Nonnull @EnumType @Nonnull @EnumType Class<T> type)
@Pure @Nullable public static @Nullable Class<?> getClass(@Nonnull @Nonnull TypeMirror typeMirror)
@Pure @Nullable public static @Nullable TypeElement getTypeElement(@Nonnull @Nonnull TypeMirror typeMirror)
@Pure @Nullable public static @Nullable Class<?> getClass(@Nullable @Nullable AnnotationValue annotationValue)
@Pure @Nullable public static <T> T getInstance(@Nullable @Nullable AnnotationValue annotationValue, @Nonnull @Nonnull Class<T> desiredType)
@Pure public static boolean isPrimitive(@Nonnull @Nonnull TypeMirror typeMirror)
@Pure @Nonnull public static @Nonnull TypeMirror getBoxedType(@Nonnull @Nonnull TypeMirror typeMirror)
@Pure @Nonnull public static @Nonnull String getAnnotationValueAsString(@Nonnull @Nonnull AnnotationValue annotationValue, @NonCaptured @Modified @Nonnull @Nonnull TypeImporter typeImporter)
@Pure @Nonnull public static @Nonnull String getAnnotationAsString(@Nonnull @Nonnull AnnotationMirror annotationMirror, @NonCaptured @Modified @Nonnull @Nonnull TypeImporter typeImporter)
@Pure @Nonnull public static @Nonnull String getAnnotationsAsString(@Nonnull @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<? extends AnnotationMirror> annotationMirrors, @NonCaptured @Modified @Nonnull @Nonnull TypeImporter typeImporter)
@Pure @Nonnull public static @Nonnull String getAnnotationsAsString(@Nonnull @Nonnull TypeMirror typeMirror, @NonCaptured @Modified @Nonnull @Nonnull TypeImporter typeImporter)
@Pure @Nullable public static @Nullable TypeMirror getTypeMirror(@Nonnull @Nonnull Class<?> type)
@Pure @Nullable public static @Nullable TypeMirror getErasedTypeMirror(@Nonnull @Nonnull Class<?> type)
@Pure public static boolean isRawlyAssignable(@Nonnull @Nonnull TypeMirror declaredType, @Nonnull @Nonnull Class<?> desiredType)
@Pure public static boolean isRawlyAssignable(@Nonnull @Nonnull Element element, @Nonnull @Nonnull Class<?> type)
@Pure public static boolean isRawSubtype(@Nonnull @Nonnull TypeMirror declaredType, @Nonnull @Nonnull Class<?> desiredType)
@Pure public static boolean isRawSubtype(@Nonnull @Nonnull Element element, @Nonnull @Nonnull Class<?> type)
@Pure public static boolean isGetter(@Nonnull @Nonnull ExecutableElement method)
@Pure public boolean isSetter(@Nonnull @Nonnull ExecutableElement method)
@Pure @Nonnull public static @Nonnull String getQualifiedName(@Nonnull @Nonnull TypeMirror typeMirror)
@Pure @Nonnull public static @Nonnull String getSimpleName(@Nonnull @Nonnull TypeMirror typeMirror)
@Pure public static boolean correspond(@Nonnull @Nonnull TypeMirror mirror, @Nonnull @Nonnull Class<?> type)
@Pure public static boolean correspond(@Nonnull @Nonnull Element element, @Nonnull @Nonnull Class<?> type)
@Pure @Nullable public static @Nullable DeclaredType getSupertype(@Nonnull @Nonnull DeclaredType sourceType, @Nonnull @Nonnull Class<?> targetType)
@Pure @Nullable public static @Nullable List<TypeMirror> getComponentTypes(@Nonnull @Nonnull TypeMirror type, @NonCaptured @Modified @Nonnull @Nonnull ErrorLogger errorLogger)
@Pure @Nullable public static @Nullable List<TypeMirror> getComponentTypes(@Nonnull @Nonnull TypeMirror type)
@Pure @Nullable public static @Nullable List<TypeMirror> getComponentTypes(@Nonnull @Nonnull Element element, @NonCaptured @Modified @Nonnull @Nonnull ErrorLogger errorLogger)
@Pure @Nullable public static @Nullable List<TypeMirror> getComponentTypes(@Nonnull @Nonnull Element element)
@Pure @Nullable public static @Nullable TypeMirror getComponentType(@Nonnull @Nonnull TypeMirror type, @NonCaptured @Modified @Nonnull @Nonnull ErrorLogger errorLogger)
@Pure @Nullable public static @Nullable TypeMirror getComponentType(@Nonnull @Nonnull TypeMirror type)
@Pure @Nullable public static @Nullable TypeMirror getComponentType(@Nonnull @Nonnull Element element, @NonCaptured @Modified @Nonnull @Nonnull ErrorLogger errorLogger)
@Pure @Nullable public static @Nullable TypeMirror getComponentType(@Nonnull @Nonnull Element element)
@Pure @Nonnull public static @Nonnull net.digitalid.utility.functional.iterables.FiniteIterable<VariableElement> getFieldsOfType(@Nonnull @Nonnull TypeElement typeElement, @Nonnull @Nonnull Class<?> fieldType)
@Pure @Nullable public static @Nullable VariableElement getFirstPublicStaticFieldOfType(@Nonnull @Nonnull TypeElement typeElement, @Nonnull @Nonnull Class<?> fieldType)
@Pure @Nullable public static @Nullable ExecutableElement getNonPrivateMethod(@Nonnull @Nonnull TypeElement typeElement, @Nonnull @Nonnull String methodName, @Nonnull @Nonnull Class<?> returnType, @Nonnull @NonNullableElements Class<?>... parameterTypes)
@Pure public static boolean hasNonPrivateMethod(@Nonnull @Nonnull TypeElement typeElement, @Nonnull @Nonnull String methodName, @Nonnull @Nonnull Class<?> returnType, @Nonnull @NonNullableElements Class<?>... parameterTypes)
@Pure public static boolean hasPublicDefaultConstructor(@Nonnull @Nonnull TypeElement typeElement)
Copyright © 2017. All rights reserved.