Package com.norconex.commons.lang
Class ClassFinder
- java.lang.Object
-
- com.norconex.commons.lang.ClassFinder
-
public final class ClassFinder extends Object
Utility class for finding names of classes implementing an interface or class in directories or JAR files.- Author:
- Pascal Essiembre
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<Class<? extends T>>findSubTypes(File file, Class<T> superClass)Finds the names of all subtypes of the super class for the suppliedFile.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.static <T> List<Class<? extends T>>findSubTypes(Class<T> superClass)Finds the names of all subtypes of the super class, scanning the roots of this class classpath.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.static <T> List<Class<? extends T>>findSubTypes(List<File> files, Class<T> superClass)Finds the names of all subtypes of the super class in list ofFilesupplied.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.
-
-
-
Method Detail
-
findSubTypes
public static <T> List<Class<? extends T>> findSubTypes(Class<T> superClass)
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
public static <T> List<Class<? extends T>> findSubTypes(List<File> files, Class<T> superClass)
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
public static <T> List<Class<? extends T>> findSubTypes(File file, Class<T> superClass)
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
-
-