Package org.opentrafficsim.road
Class ClassList
java.lang.Object
org.opentrafficsim.road.ClassList
Build a list of the classes in the project (or under a specific directory/package in the project).
Adapted from https://stackoverflow.com/questions/3923129/get-a-list-of-resources-from-classpath-directory which apparently copied the code from http://forums.devx.com/showthread.php?153784-how-to-list-resources-in-a-package. Original poster stoughto has not visited that forum after 2006.
Adapted from https://stackoverflow.com/questions/3923129/get-a-list-of-resources-from-classpath-directory which apparently copied the code from http://forums.devx.com/showthread.php?153784-how-to-list-resources-in-a-package. Original poster stoughto has not visited that forum after 2006.
Copyright (c) 2006 by stoughto! TODO replace this by something that is provably free code.
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<Class<?>>
Return a List of all the classes under a package.static Collection<String>
getResources
(Pattern pattern) For all elements of java.class.path get a Collection of resources Pattern pattern = Pattern.compile(".*"); gets all resources.static boolean
hasNonStaticFields
(Class<?> c) Report if a class has non-static fields.static boolean
isAnonymousInnerClass
(Class<?> c) Determine if a class is an anonymous inner class.static void
List the resources that match args[0], or a fixed pattern to demonstrate the use of this class.
-
Method Details
-
getResources
For all elements of java.class.path get a Collection of resources Pattern pattern = Pattern.compile(".*"); gets all resources.- Parameters:
pattern
- the pattern to match- Returns:
- the resources in the order they are found
-
classList
Return a List of all the classes under a package. Test-classes are excluded from the result.- Parameters:
packageRoot
- String package nameexcludeInterfaces
- boolean; if true; interfaces are excluded from the result- Returns:
- Collection<Class<?>>; the classes under the package
-
isAnonymousInnerClass
Determine if a class is an anonymous inner class.- Parameters:
c
- Class; the class to check- Returns:
- boolean; true if c is an anonymous inner class; false otherwise
-
hasNonStaticFields
Report if a class has non-static fields.- Parameters:
c
- Class<?>; the class- Returns:
- boolean; true if the class has non-static fields
-
main
List the resources that match args[0], or a fixed pattern to demonstrate the use of this class.- Parameters:
args
- args[0] is the pattern to match, or list all resources matching a built-in pattern if there are no args
-