Package rekit.util

Class ReflectUtils

java.lang.Object
rekit.util.ReflectUtils

public final class ReflectUtils extends Object
This class contains several methods for using Java Reflections in a proper way.
Author:
Dominik Fuchss
  • Method Details

    • loadInstances

      public static <T> Set<T> loadInstances(String searchPath, ClassLoader loader, Class<T> type)
      Load all implementations that shall be loaded (see ReflectUtils.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 loader
      type - 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 loader
      type - 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