Class ClassLoader

java.lang.Object
de.qytera.qtaf.core.reflection.ClassLoader

public class ClassLoader extends Object
This class is responsible for loading other classes and create instances from them.
  • Method Details

    • addPackageName

      public static void addPackageName(String packageName)
      Add a package that can be search for classes.
      Parameters:
      packageName - Package name
    • hasPackageName

      public static boolean hasPackageName(String packageName)
      Check if list already contains package name.
      Parameters:
      packageName - Package name
      Returns:
      true if package name is already in the list, false otherwise
    • removePackageName

      public static boolean removePackageName(String packageName)
      CRemove package name form the list.
      Parameters:
      packageName - Package name
      Returns:
      true if package name was in the list, false otherwise
    • getSubTypesOfRecursively

      public static Set<Class<?>> getSubTypesOfRecursively(Class<?> clazz, Set<Class<?>> classes, List<String> packageNames)
      Get a set of classes that are derived from the given class.
      Parameters:
      clazz - subtype
      classes - set of classes where found classes are added to
      packageNames - List of package names where to look for these classes
      Returns:
      set of classes that were found
    • getSubTypesOf

      public static Set<Class<?>> getSubTypesOf(Class<?> clazz, List<String> packageNames)
      Get a set of classes that are directly derived from the given class.
      Parameters:
      clazz - subtype
      packageNames - package names where to search for this class
      Returns:
      set of classes
    • getSubTypesOf

      public static Set<Class<?>> getSubTypesOf(Class<?> clazz)
      Get a set of classes that are directly derived from the given class.
      Parameters:
      clazz - subtype
      Returns:
      set of classes
    • getInstancesOfDirectSubtypesOf

      public static Object[] getInstancesOfDirectSubtypesOf(Class<?> clazz)
      Get all subtypes of a given class.
      Parameters:
      clazz - Instance class type
      Returns:
      Instances
    • getInstance

      Get instance of class.
      Parameters:
      c - Class
      Returns:
      instance
      Throws:
      IllegalAccessException - error if constructor is not accessible
      InvocationTargetException - error if constructor is not accessible
      InstantiationException - error if constructor is not accessible
      NoSuchMethodException - error if constructor is not accessible