Package de.qytera.qtaf.core.reflection
Class ClassLoader
java.lang.Object
de.qytera.qtaf.core.reflection.ClassLoader
This class is responsible for loading other classes and create instances from them
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPackageName(String packageName) Add a package that can be search for classesstatic ObjectgetInstance(Class<?> c) Get instance of classstatic Object[]getInstancesOfDirectSubtypesOf(Class<?> clazz) Get all sub types of a given classgetSubTypesOf(Class<?> clazz) Get a set of classes that are directly derived from the given classgetSubTypesOf(Class<?> clazz, List<String> packageNames) Get a set of classes that are directly derived from the given classGet a set of classes that are derived from the given classstatic booleanhasPackageName(String packageName) Check if list already contains package namestatic booleanremovePackageName(String packageName) CRemove package name form the list
-
Constructor Details
-
ClassLoader
public ClassLoader()
-
-
Method Details
-
addPackageName
Add a package that can be search for classes- Parameters:
packageName- Package name
-
hasPackageName
Check if list already contains package name- Parameters:
packageName- Package name- Returns:
- true if package name is already in the list, false otherwise
-
removePackageName
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- sub typeclasses- set of classes where found classes are added topackageNames- List of package names where to look for these classes- Returns:
- set of classes that were found
-
getSubTypesOf
Get a set of classes that are directly derived from the given class- Parameters:
clazz- sub typepackageNames- package names where to search for this class- Returns:
- set of classes
-
getSubTypesOf
Get a set of classes that are directly derived from the given class- Parameters:
clazz- sub type- Returns:
- set of classes
-
getInstancesOfDirectSubtypesOf
Get all sub types of a given class- Parameters:
clazz- Instance class type- Returns:
- Instances
-
getInstance
public static Object getInstance(Class<?> c) throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException Get instance of class- Parameters:
c- Class- Returns:
- instance
- Throws:
IllegalAccessException- error if constructor is not accessibleInvocationTargetException- error if constructor is not accessibleInstantiationException- error if constructor is not accessibleNoSuchMethodException- error if constructor is not accessible
-