ReflectionUtils

open class ReflectionUtils

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
Callback interface invoked on each field in the hierarchy.
Link copied to clipboard
Callback optionally used to filter fields to be operated on by a field callback.
Link copied to clipboard
Record containing handler information extracted from annotations.
Link copied to clipboard
Action to take on each method.
Link copied to clipboard
Callback optionally used to filter methods to be operated on by a method callback.

Properties

Link copied to clipboard
Pre-built FieldFilter that matches all non-static, non-final fields.
Link copied to clipboard
Pre-built MethodFilter that matches all non-bridge non-synthetic methods which are not declared on java.lang.Object.

Functions

Link copied to clipboard
open fun <T> accessibleConstructor(clazz: Class<T>, parameterTypes: Array<Class<out Any>>): Constructor<T>
Obtain an accessible constructor for the given class and parameters.
Link copied to clipboard
open fun clearCache()
Clear the internal method/field cache.
Link copied to clipboard
open fun declaresException(method: Method, exceptionType: Class<out Any>): Boolean
Determine whether the given method explicitly declares the given exception or one of its superclasses, which means that an exception of that type can be propagated as-is within a reflective invocation.
Link copied to clipboard
open fun doWithFields(clazz: Class<out Any>, fc: ReflectionUtils.FieldCallback, @Nullable ff: @Nullable ReflectionUtils.FieldFilter)
Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.
Link copied to clipboard
Invoke the given callback on all locally declared fields in the given class.
Link copied to clipboard
Perform the given callback operation on all matching methods of the given class, as locally declared or equivalent thereof (such as default methods on Java 8 based interfaces that the given class implements).
Link copied to clipboard
Perform the given callback operation on all matching methods of the given class and superclasses.
open fun doWithMethods(clazz: Class<out Any>, mc: ReflectionUtils.MethodCallback, @Nullable mf: @Nullable ReflectionUtils.MethodFilter)
Perform the given callback operation on all matching methods of the given class and superclasses (or given interface and super-interfaces).
Link copied to clipboard
open fun extractServiceName(clazz: Class<out Any>): String
Link copied to clipboard
@Nullable
open fun <A : Annotation?> findAnnotation(clazz: Class<out Any>, @Nullable annotationType: @Nullable Class<A>): @Nullable A
Find a single Annotation of annotationType on the supplied Class, traversing its interfaces, annotations, and superclasses if the annotation is not directly present on the given class itself.
@Nullable
open fun <A : Annotation?> findAnnotation(method: Method, @Nullable annotationType: @Nullable Class<A>): @Nullable A
Find a single Annotation of annotationType on the supplied Method, traversing its super methods if the annotation is not directly present on the given method itself.
Link copied to clipboard
@Nullable
open fun findField(clazz: Class<out Any>, name: String): @Nullable Field
Attempt to find a field on the supplied Class with the supplied name.
@Nullable
open fun findField(clazz: Class<out Any>, @Nullable name: @Nullable String, @Nullable type: @Nullable Class<out Any>): @Nullable Field
Attempt to find a field on the supplied Class with the supplied name and/or type.
Link copied to clipboard
@Nullable
open fun findFieldIgnoreCase(clazz: Class<out Any>, name: String): @Nullable Field
Attempt to find a field on the supplied Class with the supplied name.
Link copied to clipboard
@Nullable
open fun findMethod(clazz: Class<out Any>, name: String): @Nullable Method
Attempt to find a Method on the supplied class with the supplied name and no parameters.
@Nullable
open fun findMethod(clazz: Class<out Any>, name: String, paramTypes: @Nullable Array<Class<out Any>>): @Nullable Method
Attempt to find a Method on the supplied class with the supplied name and parameter types.
Link copied to clipboard
open fun findParameterizedType(concreteClass: Class<out Any>, rawType: Class<out Any>): ParameterizedType
Walks the type hierarchy to find where the given rawType interface was parameterized.
Link copied to clipboard
open fun getAllDeclaredMethods(leafClass: Class<out Any>): Array<Method>
Get all declared methods on the leaf class and all superclasses.
Link copied to clipboard
open fun getDeclaredMethods(clazz: Class<out Any>): Array<Method>
Variant of getDeclaredMethods that uses a local cache in order to avoid new Method instances.
Link copied to clipboard
@Nullable
open fun getField(field: Field, @Nullable target: @Nullable Any): @Nullable Any
Get the field represented by the supplied field object on the specified target object.
Link copied to clipboard
open fun getUniqueDeclaredMethods(leafClass: Class<out Any>): Array<Method>
open fun getUniqueDeclaredMethods(leafClass: Class<out Any>, @Nullable mf: @Nullable ReflectionUtils.MethodFilter): Array<Method>
Get the unique set of declared methods on the leaf class and all superclasses.
Link copied to clipboard
Handle the given invocation target exception.
Link copied to clipboard
Handle the given reflection exception.
Link copied to clipboard
open fun hasServiceAnnotation(clazz: Class<out Any>): Boolean
Link copied to clipboard
Link copied to clipboard
open fun hasWorkflowAnnotation(clazz: Class<out Any>): Boolean
Link copied to clipboard
@Nullable
open fun invokeMethod(method: Method, @Nullable target: @Nullable Any): @Nullable Any
Invoke the specified Method against the supplied target object with no arguments.
@Nullable
open fun invokeMethod(method: Method, @Nullable target: @Nullable Any, @Nullable args: Array<@Nullable Any>): @Nullable Any
Invoke the specified Method against the supplied target object with the supplied arguments.
Link copied to clipboard
open fun isCglibRenamedMethod(renamedMethod: Method): Boolean
Determine whether the given method is a CGLIB 'renamed' method, following the pattern "CGLIB$methodName$0".
Link copied to clipboard
open fun isEqualsMethod(@Nullable method: @Nullable Method): Boolean
Determine whether the given method is an "equals" method.
Link copied to clipboard
open fun isHashCodeMethod(@Nullable method: @Nullable Method): Boolean
Determine whether the given method is a "hashCode" method.
Link copied to clipboard
open fun isKotlinClass(clazz: Class<out Any>): Boolean
Link copied to clipboard
open fun isObjectMethod(@Nullable method: @Nullable Method): Boolean
Determine whether the given method is originally declared by Object.
Link copied to clipboard
Determine whether the given field is a "public static final" constant.
Link copied to clipboard
open fun isToStringMethod(@Nullable method: @Nullable Method): Boolean
Determine whether the given method is a "toString" method.
Link copied to clipboard
open fun makeAccessible(ctor: Constructor<out Any>)
Make the given constructor accessible, explicitly setting it accessible if necessary.
open fun makeAccessible(field: Field)
Make the given field accessible, explicitly setting it accessible if necessary.
open fun makeAccessible(method: Method)
Make the given method accessible, explicitly setting it accessible if necessary.
Link copied to clipboard
open fun mustHaveHandlerAnnotation(@NonNull method: @NonNull Method): ReflectionUtils.HandlerInfo
Link copied to clipboard
open fun mustHaveServiceAnnotation(clazz: Class<out Any>)
Link copied to clipboard
Link copied to clipboard
open fun mustHaveWorkflowAnnotation(clazz: Class<out Any>)
Link copied to clipboard
open fun rethrowException(@Nullable throwable: @Nullable Throwable)
Rethrow the given exception, which is presumably the target exception of an InvocationTargetException.
Link copied to clipboard
open fun rethrowRuntimeException(@Nullable ex: @Nullable Throwable)
Rethrow the given exception, which is presumably the target exception of an InvocationTargetException.
Link copied to clipboard
open fun setField(field: Field, @Nullable target: @Nullable Any, @Nullable value: @Nullable Any)
Set the field represented by the supplied field object on the specified target object to the specified value.
Link copied to clipboard
open fun shallowCopyFieldState(src: Any, dest: Any)
Given the source object and the destination, which must be the same class or a subclass, copy all fields, including inherited fields.