public final class Classpath extends AbstractRootSlice
Important:All slices used for assertions must stem from the same Classpath. Otherwise the behaviour is undefined.
Constructor and Description |
---|
Classpath()
Creates a Classpath instance by using the default resolver.
|
Classpath(ClassResolver resolver)
Creates a Classpath with some custom resolver.
|
Modifier and Type | Method and Description |
---|---|
Clazz |
asClazz(Class<?> classImpl)
|
Clazz |
asClazz(String classname)
Creates a
Clazz form a classname. |
ConcreteSlice |
duplicates()
Returns a slice of all duplicate .class files detected by the underlying
ClassResolver . |
Root |
rootOf(Class<?> clazz)
|
Root |
rootOf(File rootFile)
Returns the Root for classes directory or .jar file located on the classpath.
|
Root |
rootOfClass(String classname)
Return the
Root of some class given by its classname. |
Slice |
sliceOf(Class<?>... classes)
Returns a
Slice for a concrete list of Java classes. |
contains, getClazzes, packageOf, packageOf, packageOf, packageTreeOf, packageTreeOf, packageTreeOf, slice, slice
dependencyClosure, getDependencies, minus, minus, minus, minus, named, partitionBy, partitionBy, partitionByPackage, plus, plus, slice, slice, uses
public Classpath()
public Classpath(ClassResolver resolver)
resolver
- the resolver to resolve the classespublic Clazz asClazz(String classname)
Clazz
form a classname.
Returns the first matching class on this classpath, if there is one. If no such class
could be found it tries to use the current ClassLoader
to look up the class.
Of both fail a place-holder object will be returned that contains nothing but the classname.classname
- the classnamepublic Clazz asClazz(Class<?> classImpl)
Clazz
form a Java Class
.
Returns a Clazz matching exactly to the passed Class
. If there are alternatives on this
Classpath they will be linked to the Clazz returned.
Beware:Creating a Clazz for a Class not found on the current Classpath for which an other
class of the same name is on the Classpath my alter an existing Clazz by adding an alternative.
This rare case may change the result of duplicates()
or specific slice assertions.
classImpl
- the Java classpublic ConcreteSlice duplicates()
ClassResolver
.
Hence, for each entry in this slice there are at least two .class files with the same classname but
different URI's.public Root rootOfClass(String classname)
Root
of some class given by its classname.classname
- the fully qualified name of the classpublic Root rootOf(File rootFile)
rootFile
- the file to get the root forIllegalArgumentException
- if rootFile could not be found on the classpathpublic Slice sliceOf(Class<?>... classes)
Slice
for a concrete list of Java classes.
The classes do not necessarily have to be on this Classpath.classes
- the classesasClazz(Class)
Copyright © 2017–2023 Hans Jörg Heßmann. All rights reserved.