Package me.datafox.dfxengine.utils
Class ClassUtils
java.lang.Object
me.datafox.dfxengine.utils.ClassUtils
Utilities for classes and reflection.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfilterInstanceAndCast
(Class<C> aClass) static <T,
C> Stream <C> filterInstanceAndCast
(T input, Class<C> aClass) static <T extends Annotation>
Optional<T> getAnnotationFromArray
(Annotation[] arr, Class<T> annotationType) static <T> List
<Constructor<T>> getConstructorsWithAnnotation
(Class<T> aClass, Class<? extends Annotation> annotation) getFieldsWithAnnotation
(Class<T> aClass, Class<? extends Annotation> annotation) getMethodsWithAnnotation
(Class<T> aClass, Class<? extends Annotation> annotation) getSuperclassesFor
(Class<? super T> aClass)
-
Constructor Details
-
Method Details
-
getSuperclassesFor
- Type Parameters:
T
- type of the class- Parameters:
aClass
- class- Returns:
- Stream of the class and all superclasses and superinterfaces of the class
-
getConstructorsWithAnnotation
public static <T> List<Constructor<T>> getConstructorsWithAnnotation(Class<T> aClass, Class<? extends Annotation> annotation) - Type Parameters:
T
- type of the class- Parameters:
aClass
- classannotation
- annotation- Returns:
- List of all declared constructors of the class with the annotation
-
getFieldsWithAnnotation
public static <T> List<Field> getFieldsWithAnnotation(Class<T> aClass, Class<? extends Annotation> annotation) - Type Parameters:
T
- type of the class- Parameters:
aClass
- classannotation
- annotation- Returns:
- List of all declared fields of the class with the annotation
-
getMethodsWithAnnotation
public static <T> List<Method> getMethodsWithAnnotation(Class<T> aClass, Class<? extends Annotation> annotation) - Type Parameters:
T
- type of the class- Parameters:
aClass
- classannotation
- annotation- Returns:
- List of all declared methods of the class with the annotation
-
getAnnotationFromArray
public static <T extends Annotation> Optional<T> getAnnotationFromArray(Annotation[] arr, Class<T> annotationType) - Type Parameters:
T
- type of the annotation- Parameters:
arr
- array of annotationsannotationType
- annotation type- Returns:
- Optional containing the first annotation in the array matching the type, or empty if no matches are found
-
filterInstanceAndCast
-
filterInstanceAndCast
-