Instantiate a new ClassFinder
that will search the specified
classpath, or the default classpath, if no classpath is defined.
Instantiate a new ClassFinder
that will search the specified
classpath, or the default classpath, if no classpath is defined.
the classpath, which is a sequence of File
objects representing directories, jars and zip files
to search. Defaults to classpath
if empty.
a new ClassFinder
object
Create a map from a Stream of ClassInfo objects.
Create a map from a Stream of ClassInfo objects. The resulting map is indexed by class name.
a map of (classname, ClassInfo
) pairs
Create a map from an Iterator of ClassInfo objects.
Create a map from an Iterator of ClassInfo objects. The resulting map is indexed by class name.
a map of (classname, ClassInfo
) pairs
Convenient method for getting the standard JVM classpath, into a
variable suitable for use with the find()
method.
Convenient method for getting the standard JVM classpath, into a
variable suitable for use with the find()
method.
the classpath, as a list of File
objects
Variant of concreteSubclasses()
that takes a string class name and
a map, rather than a Class
and a map.
Variant of concreteSubclasses()
that takes a string class name and
a map, rather than a Class
and a map.
the name of the class for which to find descendent concrete subclasses
the iterator of ClassInfo
objects to search
an iterator of ClassInfo
objects that are concrete subclasses
of ancestor
. The iterator will be empty if no matching classes
could be found.
concreteSubclasses(String, Iterator[ClassInfo])
concreteSubclasses(String, Stream[ClassInfo])
concreteSubclasses(Class[_], Map[String, ClassInfo])
Variant of concreteSubclasses()
that takes a class and a Map
ClassInfo
objects.
Variant of concreteSubclasses()
that takes a class and a Map
ClassInfo
objects.
the Class
object of the superclass or trait for which
to find descendent concrete subclasses
the iterator of ClassInfo
objects to search
an iterator of ClassInfo
objects that are concrete subclasses
of ancestor
. The iterator will be empty if no matching classes
could be found.
concreteSubclasses(Class[_], Iterator[ClassInfo])
concreteSubclasses(Class[_], Stream[ClassInfo])
Variant of concreteSubclasses()
that takes a string class name and
an Iterator
of ClassInfo
objects, rather than a Class
and an
Iterator
.
Variant of concreteSubclasses()
that takes a string class name and
an Iterator
of ClassInfo
objects, rather than a Class
and an
Iterator
.
the name of the class for which to find descendent concrete subclasses
the stream of ClassInfo
objects to search
an iterator of ClassInfo
objects that are concrete subclasses
of ancestor
. The iterator will be empty if no matching classes
could be found.
val finder = ClassFinder(myPath) val classes = finder.getClasses // classes is an Stream[ClassInfo] // Of course, it's easier just to call the version that takes a // Stream... ClassFinder.concreteSubclasses("org.example.Foo", classes.toIterator)
concreteSubclasses(Class[_], Iterator[ClassInfo])
concreteSubclasses(String, Stream[ClassInfo])
Variant of concreteSubclasses()
that takes a class and an Iterator
of ClassInfo
objects, rather than a Class
and a Stream
.
Variant of concreteSubclasses()
that takes a class and an Iterator
of ClassInfo
objects, rather than a Class
and a Stream
.
the Class
object of the superclass or trait for which
to find descendent concrete subclasses
the iterator of ClassInfo
objects to search
an iterator of ClassInfo
objects that are concrete subclasses
of ancestor
. The iterator will be empty if no matching classes
could be found.
val finder = ClassFinder(myPath) val classes = finder.getClasses // classes is an Stream[ClassInfo] // Of course, it's easier just to call the version that takes a // Stream... ClassFinder.concreteSubclasses(classOf[Baz], classes.toIterator)
concreteSubclasses(Class[_], Stream[ClassInfo])
Variant of concreteSubclasses()
that takes a string class name and
a Stream
of ClassInfo
objects, rather than a Class
and a Stream
.
Variant of concreteSubclasses()
that takes a string class name and
a Stream
of ClassInfo
objects, rather than a Class
and a Stream
.
the name of the class for which to find descendent concrete subclasses
the stream of ClassInfo
objects to search
an iterator of ClassInfo
objects that are concrete subclasses
of ancestor
. The iterator will be empty if no matching classes
could be found.
concreteSubclasses(Class[_], Stream[ClassInfo])
Convenience method that scans the specified classes for all concrete classes that are subclasses of a superclass or trait.
Convenience method that scans the specified classes for all concrete classes that are subclasses of a superclass or trait. A subclass, in this definition, is a class that directly or indirectly (a) implements an interface (if the named class is an interface) or (b) extends a subclass (if the named class is a class). The class must be concrete, so intermediate abstract classes are not returned, though any children of such abstract classes will be.
WARNINGS
This method converts the stream to a map of classes, for easier lookup. Thus, upon its return, the stream will be empty. You can certainly recreate the stream, but at a cost. If you need to make multiple calls to this method with the same classpath, consider converting the stream to a map first, as shown below:
val finder = ClassFinder(myPath) val classes = finder.getClasses // classes is an Stream[ClassInfo] val classMap = ClassFinder.classInfoMap // runs the stream out, once val foos = ClassFinder.concreteSubclasses(classOf[org.example.Foo], classMap) val bars = ClassFinder.concreteSubclasses(classOf[Bar], classMap)
This method can chew up a lot of temporary heap space, if called with a large classpath.
the Class
object of the superclass or trait for which
to find descendent concrete subclasses
the stream of ClassInfo
objects to search
an iterator of ClassInfo
objects that are concrete subclasses
of ancestor
. The iterator will be empty if no matching classes
could be found.
The entrance to the factory floor, providing methods for finding and filtering classes.