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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPackageName(String packageName) Add a package that can be search for classes.static ObjectgetInstance(Class<?> c) Get instance of class.static Object[]getInstancesOfDirectSubtypesOf(Class<?> clazz) Get all subtypes of a given class.getSubTypesOf(Class<?> clazz) Get a set of classes that are directly derived from the given class.getSubTypesOf(Class<?> clazz, List<String> packageNames) Get a set of classes that are directly derived from the given class.Get a set of classes that are derived from the given class.static booleanhasPackageName(String packageName) Check if list already contains package name.static booleanremovePackageName(String packageName) CRemove package name form the list.
-
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- subtypeclasses- 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- subtypepackageNames- 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- subtype- Returns:
- set of classes
-
getInstancesOfDirectSubtypesOf
Get all subtypes 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
-