Package ru.iopump.qa.util
Class ReflectionUtil
- java.lang.Object
-
- ru.iopump.qa.util.ReflectionUtil
-
public final class ReflectionUtil extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> @NonNull java.util.Collection<T>createImplementations(java.lang.Class<T> interfaceOrSuperClass, java.lang.String packageName)Find all implementations of passed type and create it via non-arg constructor.static <T> @NonNull java.util.Collection<java.lang.Class<T>>findImplementations(java.lang.Class<T> interfaceOrSuperClass, java.lang.String packageName)Find all implementations of passed type.static @NonNull java.util.Optional<java.lang.Class<?>>findOneClassBySimpleNameInJdk(java.lang.String classSimpleName)Find class in JDK packages by his simple name.static @NonNull java.util.Collection<java.lang.Class<?>>getGenericTypes(java.lang.reflect.Field field)Get collection of parameters types of passedField.
-
-
-
Method Detail
-
getGenericTypes
@NonNull public static @NonNull java.util.Collection<java.lang.Class<?>> getGenericTypes(@Nullable java.lang.reflect.Field field)Get collection of parameters types of passedField. You can get generic types only fromField(orClass). For object this information is been removed. Null-safe.- Parameters:
field- field with parameters type- Returns:
- collection of generic types
-
createImplementations
@NonNull public static <T> @NonNull java.util.Collection<T> createImplementations(@Nullable java.lang.Class<T> interfaceOrSuperClass, @Nullable java.lang.String packageName)Find all implementations of passed type and create it via non-arg constructor. Null-safe.- Type Parameters:
T- Expected type- Parameters:
interfaceOrSuperClass- Base typepackageName- full package name to search- Returns:
- Collection of children.
-
findImplementations
@NonNull public static <T> @NonNull java.util.Collection<java.lang.Class<T>> findImplementations(@Nullable java.lang.Class<T> interfaceOrSuperClass, @Nullable java.lang.String packageName)Find all implementations of passed type. Null-safe.- Type Parameters:
T- Expected type- Parameters:
interfaceOrSuperClass- Base typepackageName- full package name to search. NULL means all packages.- Returns:
- Collection of children.
-
findOneClassBySimpleNameInJdk
@NonNull public static @NonNull java.util.Optional<java.lang.Class<?>> findOneClassBySimpleNameInJdk(@Nullable java.lang.String classSimpleName)Find class in JDK packages by his simple name. Search will be only in 'java.lang' and 'java.util' because. For example 'String' will findStringclass. Null-safe.- Parameters:
classSimpleName- Simple class name (not full) in JDK.- Returns:
- Related class
-
-