Package htsjdk.utils
Class ClassFinder
java.lang.Object
htsjdk.utils.ClassFinder
Utility class that can scan for classes in the classpath and find all the ones
annotated with a particular annotation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Scans the classpath for classes within the specified package and sub-packages that extend the parentType.Fetches the set of classes discovered so far.Fetches the set of classes discovered so far, subsetted down to concrete (non-abstract/interface) classes onlyprotected void
handleItem
(String name) Checks an item to see if it is a class and is annotated with the specified annotation.static boolean
isConcrete
(Class<?> clazz) Determines whether or not the specified class is concrete (ie., non-abstract and non-interface)protected void
Scans a directory on the filesystem for classes.protected void
Scans the entries in a ZIP/JAR file for classes under the parent package.toClassName
(String filename) Convert a filename to a class name by removing '.class' and converting '/'s to '.'s.
-
Constructor Details
-
ClassFinder
public ClassFinder() -
ClassFinder
-
ClassFinder
- Throws:
IOException
-
-
Method Details
-
toClassName
Convert a filename to a class name by removing '.class' and converting '/'s to '.'s. -
find
Scans the classpath for classes within the specified package and sub-packages that extend the parentType. This method can be called repeatedly with different packages. Classes are accumulated internally and can be accessed by callinggetClasses()
. -
scanJar
Scans the entries in a ZIP/JAR file for classes under the parent package.- Parameters:
file
- the jar file to be scannedpackagePath
- the top level package to start from- Throws:
IOException
-
scanDir
Scans a directory on the filesystem for classes.- Parameters:
file
- the directory or file to examinepath
- the package path acculmulated so far (e.g. edu/mit/broad)
-
handleItem
Checks an item to see if it is a class and is annotated with the specified annotation. If so, adds it to the set, otherwise ignores it.- Parameters:
name
- the path equivelant to the package + class/item name
-
getClasses
Fetches the set of classes discovered so far. -
getConcreteClasses
Fetches the set of classes discovered so far, subsetted down to concrete (non-abstract/interface) classes only- Returns:
- subset of classes discovered so far including only concrete (non-abstract/interface) classes
-
isConcrete
Determines whether or not the specified class is concrete (ie., non-abstract and non-interface)- Parameters:
clazz
- class to check- Returns:
- true if the class is neither abstract nor an interface, otherwise false
-