Class ReflectionUtils
java.lang.Object
io.fluxcapacitor.common.reflection.ReflectionUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TasInstance(Object classOrInstance) static booleanclassExists(String className) static Class<?> classForName(String type) static Class<?> classForName(String type, Class<?> defaultClass) static <T> TconvertAnnotation(Annotation annotation, Class<? extends T> returnType) static <V> VcopyFields(V source, V target) static booleandeclaresField(Class<?> target, String fieldName) determineCommonAncestors(Collection<?> elements) static <T extends AccessibleObject>
TensureAccessible(T member) getAllMethods(Class<?> type) getAnnotatedFields(Class<?> target, Class<? extends Annotation> annotation) getAnnotatedFields(Object target, Class<? extends Annotation> annotation) getAnnotatedMethods(Class<?> target, Class<? extends Annotation> annotation) getAnnotatedMethods(Object target, Class<? extends Annotation> annotation) static List<? extends AccessibleObject> getAnnotatedProperties(Class<?> target, Class<? extends Annotation> annotation) static Optional<? extends AccessibleObject> getAnnotatedProperty(Class<?> target, Class<? extends Annotation> annotation) static Optional<? extends AccessibleObject> getAnnotatedProperty(Object target, Class<? extends Annotation> annotation) getAnnotatedPropertyValue(Object target, Class<? extends Annotation> annotation) static Collection<Object> getAnnotatedPropertyValues(Object target, Class<? extends Annotation> annotation) static <A extends Annotation>
Optional<A> getAnnotation(AnnotatedElement m, Class<A> a) static <T> Optional<T> getAnnotationAs(Annotation annotation, Class<? extends Annotation> targetAnnotation, Class<? extends T> returnType) static <T> Optional<T> getAnnotationAs(Class<?> target, Class<? extends Annotation> annotationType, Class<T> returnType) static <T> Optional<T> getAnnotationAs(AnnotatedElement member, Class<? extends Annotation> annotationType, Class<? extends T> returnType) static Class<?> getCollectionElementType(AccessibleObject fieldOrMethod) getCollectionElementType(Type parameterizedType) static Class<?> getEnclosingClass(AccessibleObject fieldOrMethod) static <A extends Annotation>
Optional<A> getFieldAnnotation(Field f, Class<? extends Annotation> a) static <T> Optional<T> getFieldValue(String fieldName, Object target) static <T extends Type>
TgetFirstTypeArgument(Type genericType) static TypegetGenericPropertyType(AccessibleObject fieldOrMethod) static TypegetGenericType(Class<?> candidate, Class<?> wantedClass) static <A extends Annotation>
Optional<A> getMemberAnnotation(Class<?> type, String memberName, Class<? extends Annotation> a) static <A extends Annotation>
Optional<A> getMethodAnnotation(Executable m, Class<? extends Annotation> a) static <A extends Annotation>
List<A> getMethodAnnotations(Executable m, Class<? extends Annotation> a) getMethodOverrideHierarchy(Method method) static StringgetName(AccessibleObject fieldOrMethod) static <A extends Annotation>
Optional<A> getPackageAnnotation(Package p, Class<A> annotationType) static Collection<? extends Annotation> static Collection<? extends Annotation> getPackageAnnotations(Package p, boolean recursive) static intgetParameterIndex(Parameter parameter) getParameterOverrideHierarchy(Parameter parameter) static <T> Optional<T> getPropertyAnnotation(String propertyPath, Object target) static StringgetPropertyName(AccessibleObject property) static Class<?> getPropertyType(AccessibleObject fieldOrMethod) static StringgetSimpleName(String fullyQualifiedName) static <A extends Annotation>
AgetTypeAnnotation(Class<?> type, Class<? extends Annotation> annotationType) static Collection<? extends Annotation> getTypeAnnotations(Class<?> type) static <T extends Type>
TgetTypeArgument(Type genericType, int index) getTypeArguments(Type genericType) static ObjectgetValue(AccessibleObject fieldOrMethod, Object target) static ObjectgetValue(AccessibleObject fieldOrMethod, Object target, boolean forceAccess) static booleanhas(Class<? extends Annotation> annotationClass, Method method) static booleanhas(Class<? extends Annotation> annotationClass, Parameter parameter) static booleanhasProperty(String propertyPath, Object target) static Class<?> static booleanisAnnotationPresent(Class<?> type, Class<? extends Annotation> annotationType) static booleanisAnnotationPresent(Parameter parameter, Class<? extends Annotation> annotationType) static booleanisConstant(Object value) static booleanstatic booleanisMethodAnnotationPresent(Class<?> target, Class<? extends Annotation> annotation) static booleanisNullable(Parameter parameter) static booleanisOrHas(Annotation annotation, Class<? extends Annotation> annotationType) static booleanisStatic(Executable method) static <T> Optional<T> readProperty(String propertyPath, Object target) static voidstatic voidstatic voidwriteProperty(String propertyPath, Object target, Object value)
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
getMethodOverrideHierarchy
-
getParameterOverrideHierarchy
-
isKotlinReflectionSupported
public static boolean isKotlinReflectionSupported() -
ifClass
-
getAllMethods
-
getMethod
-
getAnnotatedProperties
public static List<? extends AccessibleObject> getAnnotatedProperties(Class<?> target, Class<? extends Annotation> annotation) -
getAnnotatedProperty
public static Optional<? extends AccessibleObject> getAnnotatedProperty(Object target, Class<? extends Annotation> annotation) -
getAnnotatedProperty
public static Optional<? extends AccessibleObject> getAnnotatedProperty(Class<?> target, Class<? extends Annotation> annotation) -
getAnnotatedPropertyValue
public static Optional<Object> getAnnotatedPropertyValue(Object target, Class<? extends Annotation> annotation) -
getAnnotatedPropertyValues
public static Collection<Object> getAnnotatedPropertyValues(Object target, Class<? extends Annotation> annotation) -
getPropertyName
-
getAnnotatedMethods
public static List<Method> getAnnotatedMethods(Class<?> target, Class<? extends Annotation> annotation) -
getAnnotatedMethods
public static List<Method> getAnnotatedMethods(Object target, Class<? extends Annotation> annotation) -
isMethodAnnotationPresent
public static boolean isMethodAnnotationPresent(Class<?> target, Class<? extends Annotation> annotation) -
getAnnotatedFields
public static List<Field> getAnnotatedFields(Class<?> target, Class<? extends Annotation> annotation) -
getAnnotatedFields
-
isAnnotationPresent
public static boolean isAnnotationPresent(Class<?> type, Class<? extends Annotation> annotationType) -
getTypeAnnotation
public static <A extends Annotation> A getTypeAnnotation(Class<?> type, Class<? extends Annotation> annotationType) -
getTypeAnnotations
-
getPackageAnnotation
public static <A extends Annotation> Optional<A> getPackageAnnotation(Package p, Class<A> annotationType) -
getPackageAnnotations
-
getPackageAnnotations
-
readProperty
-
getTypeArguments
-
getFirstTypeArgument
-
getTypeArgument
-
getPropertyAnnotation
-
hasProperty
-
getFieldValue
-
getValue
-
getValue
-
getName
-
getEnclosingClass
-
getPropertyType
-
getGenericPropertyType
-
writeProperty
-
isOrHas
-
getField
-
getCallerClass
-
isNullable
-
asInstance
-
getParameterIndex
-
determineCommonAncestors
-
getPackageAndParentPackages
-
getMemberAnnotation
public static <A extends Annotation> Optional<A> getMemberAnnotation(Class<?> type, String memberName, Class<? extends Annotation> a) -
isStatic
-
isConstant
-
isAnnotationPresent
public static boolean isAnnotationPresent(Parameter parameter, Class<? extends Annotation> annotationType) -
getGenericType
-
getCollectionElementType
-
getCollectionElementType
-
declaresField
-
setField
-
setField
-
ensureAccessible
-
getAnnotation
-
getAnnotationAs
public static <T> Optional<T> getAnnotationAs(Class<?> target, Class<? extends Annotation> annotationType, Class<T> returnType) -
getAnnotationAs
public static <T> Optional<T> getAnnotationAs(AnnotatedElement member, Class<? extends Annotation> annotationType, Class<? extends T> returnType) -
getAnnotationAs
public static <T> Optional<T> getAnnotationAs(Annotation annotation, Class<? extends Annotation> targetAnnotation, Class<? extends T> returnType) -
convertAnnotation
-
has
-
has
-
getFieldAnnotation
public static <A extends Annotation> Optional<A> getFieldAnnotation(Field f, Class<? extends Annotation> a) -
getMethodAnnotation
public static <A extends Annotation> Optional<A> getMethodAnnotation(Executable m, Class<? extends Annotation> a) -
getMethodAnnotations
public static <A extends Annotation> List<A> getMethodAnnotations(Executable m, Class<? extends Annotation> a) -
copyFields
public static <V> V copyFields(V source, V target) -
classForName
-
classForName
-
classExists
-
getSimpleName
-