Package rekit.util
Class ReflectUtils
java.lang.Object
rekit.util.ReflectUtils
This class contains several methods for using Java Reflections in a proper
way.
- Author:
- Dominik Fuchss
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceThis annotation has to be applied to Classes which shall be loaded as implementation of a specific class and shall be instantiated.
If a class wants to be loaded, the class needs a default constructor -
Method Summary
Modifier and TypeMethodDescriptiongetClasses(String searchPath, ClassLoader loader, Class<T> type) Get all implementations of a class by search path (-> classpath) .getClassesAnnotated(String searchPath, Class<? extends Annotation> annotation) Get all classes which are annotated with ...static <T> Set<T>loadInstances(String searchPath, ClassLoader loader, Class<T> type) Load all implementations that shall be loaded (seeReflectUtils.LoadMe) of a class by search path (-> classpath).
-
Method Details
-
loadInstances
Load all implementations that shall be loaded (seeReflectUtils.LoadMe) of a class by search path (-> classpath).
If a class wants to be loaded, the class needs a default constructor- Type Parameters:
T- the class-type- Parameters:
searchPath- the search path (e.g. java.lang)loader- the class loadertype- the class- Returns:
- a set of instances of the found classes
-
getClasses
public static <T> Set<Class<? extends T>> getClasses(String searchPath, ClassLoader loader, Class<T> type) Get all implementations of a class by search path (-> classpath) .- Type Parameters:
T- the class-type- Parameters:
searchPath- the search path (e.g. java.lang)loader- the class loadertype- the class- Returns:
- a set of the found classes
-
getClassesAnnotated
public static Set<Class<?>> getClassesAnnotated(String searchPath, Class<? extends Annotation> annotation) Get all classes which are annotated with ... by search path (-> classpath).
No subtypes will be returned except if they are annotated too.- Parameters:
searchPath- the search path (e.g. java.lang)annotation- the class annotation- Returns:
- a set of the found classes
-