Package com.norconex.commons.lang
Class ClassFinder
java.lang.Object
com.norconex.commons.lang.ClassFinder
Utility class for finding names of classes implementing an interface or class
in directories or JAR files.
-
Method Summary
Modifier and TypeMethodDescriptionfindSubTypes(File file, Class<T> superClass) Finds the names of all subtypes of the super class for the suppliedFile.findSubTypes(File file, Class<T> superClass, Predicate<String> predicate) Finds the names of all subtypes of the super class for the suppliedFile.findSubTypes(Class<T> superClass) Finds the names of all subtypes of the super class, scanning the roots of this class classpath.findSubTypes(Class<T> superClass, Predicate<String> predicate) Finds the names of all subtypes of the super class, scanning the roots of this class classpath.findSubTypes(List<File> files, Class<T> superClass) Finds the names of all subtypes of the super class in list ofFilesupplied.Finds the names of all subtypes of the super class in list ofFilesupplied.
-
Method Details
-
findSubTypes
Finds the names of all subtypes of the super class, scanning the roots of this class classpath. This method is null-safe. If no classes are found, an empty list will be returned.- Type Parameters:
T- super type- Parameters:
superClass- the class from which to find subtypes- Returns:
- list of class names
- Since:
- 1.4.0
-
findSubTypes
public static <T> List<Class<? extends T>> findSubTypes(Class<T> superClass, Predicate<String> predicate) Finds the names of all subtypes of the super class, scanning the roots of this class classpath. This method is null-safe. If no classes are found, an empty list will be returned.- Type Parameters:
T- super type- Parameters:
superClass- the class from which to find subtypespredicate- filter to keep classes testingtrue- Returns:
- list of class names
- Since:
- 2.0.0
-
findSubTypes
Finds the names of all subtypes of the super class in list ofFilesupplied. This method is null-safe. If no classes are found, an empty list will be returned.- Type Parameters:
T- super type- Parameters:
files- directories and/or JARs to scan for classessuperClass- the class from which to find subtypes- Returns:
- list of class names
- Since:
- 1.4.0
-
findSubTypes
public static <T> List<Class<? extends T>> findSubTypes(List<File> files, Class<T> superClass, Predicate<String> accept) Finds the names of all subtypes of the super class in list ofFilesupplied. This method is null-safe. If no classes are found, an empty list will be returned.- Type Parameters:
T- super type- Parameters:
files- directories and/or JARs to scan for classessuperClass- the class from which to find subtypesaccept- filter to keep classes testingtrue- Returns:
- list of class names
- Since:
- 2.0.0
-
findSubTypes
Finds the names of all subtypes of the super class for the suppliedFile. This method is null-safe. If no classes are found, an empty list will be returned. If the file is null or does not exists, or if it is not a JAR or directory, an empty string list will be returned.- Type Parameters:
T- super type- Parameters:
file- directory or JAR to scan for classessuperClass- the class from which to find subtypes- Returns:
- list of class names
- Since:
- 1.4.0
-
findSubTypes
public static <T> List<Class<? extends T>> findSubTypes(File file, Class<T> superClass, Predicate<String> predicate) Finds the names of all subtypes of the super class for the suppliedFile. This method is null-safe. If no classes are found, an empty list will be returned. If the file is null or does not exists, or if it is not a JAR or directory, an empty string list will be returned.- Type Parameters:
T- super type- Parameters:
file- directory or JAR to scan for classessuperClass- the class from which to find subtypespredicate- filter to keep classes testingtrue- Returns:
- list of class names
- Since:
- 2.0.0
-