public class ClassPool
extends java.lang.Object
Clazz
instances. They can be enumerated or retrieved by name. They can
also be accessed by means of class visitors.Constructor and Description |
---|
ClassPool()
Creates a new empty ClassPool.
|
ClassPool(ClassPool classPool)
Creates a new ClassPool with the given classes.
|
ClassPool(Clazz... classes)
Creates a new ClassPool with the given classes.
|
ClassPool(java.lang.Iterable<? extends Clazz> classes)
Creates a new ClassPool with the given classes.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(ClassPoolVisitor classPoolVisitor)
Applies the given ClassPoolVisitor to the class pool.
|
void |
addClass(Clazz clazz)
Adds the given Clazz to the class pool.
|
void |
addClass(java.lang.String name,
Clazz clazz)
Adds the given Clazz with the given name to the class pool.
|
void |
classAccept(java.lang.String className,
ClassVisitor classVisitor)
Applies the given ClassVisitor to the class with the given name, if it is present in the class
pool.
|
java.lang.Iterable<Clazz> |
classes()
Returns an Iterable of all classes in the class pool.
|
void |
classesAccept(ClassVisitor classVisitor)
Applies the given ClassVisitor to all classes in the class pool, in random order.
|
void |
classesAccept(java.util.List classNameFilter,
ClassVisitor classVisitor)
Applies the given ClassVisitor to all matching classes in the class pool.
|
void |
classesAccept(java.lang.String classNameFilter,
ClassVisitor classVisitor)
Applies the given ClassVisitor to all matching classes in the class pool.
|
void |
classesAccept(StringMatcher classNameFilter,
ClassVisitor classVisitor)
Applies the given ClassVisitor to all matching classes in the class pool.
|
void |
classesAcceptAlphabetically(ClassVisitor classVisitor)
Applies the given ClassVisitor to all classes in the class pool, in sorted order.
|
java.util.Iterator<java.lang.String> |
classNames()
Returns an Iterator of all class names in the class pool.
|
void |
clear()
Clears the class pool.
|
boolean |
contains(Clazz clazz)
Checks whether the given class exists in the class pool.
|
Clazz |
getClass(java.lang.String className)
Returns a Clazz from the class pool based on its name.
|
ClassPool |
refreshedCopy()
Returns a ClassPool with the same classes, but with the keys that correspond to the names of
the class instances.
|
<T> java.util.Map<java.lang.String,T> |
refreshedKeysCopy(java.util.Map<java.lang.String,T> map)
Returns a Map with the same contents as the given map, but with keys that have been mapped
based from the names in the class pool to the names in the corresponding classes.
|
<T> java.util.Map<T,java.lang.String> |
refreshedValuesCopy(java.util.Map<T,java.lang.String> map)
Returns a Map with the same contents as the given map, but with values that have been mapped
based from the names in the class pool to the names in the corresponding classes.
|
void |
removeClass(Clazz clazz)
Removes the given Clazz from the class pool.
|
Clazz |
removeClass(java.lang.String className)
Removes the Class with the specified name from the class pool.
|
java.util.Map<Clazz,java.lang.String> |
reverseMapping()
Returns a Map that represents a mapping from every Clazz in the ClassPool to its original name.
|
int |
size()
Returns the number of classes in the class pool.
|
public ClassPool()
public ClassPool(Clazz... classes)
classes
- the classes to be added.public ClassPool(java.lang.Iterable<? extends Clazz> classes)
classes
- the classes to be added.public ClassPool(ClassPool classPool)
classPool
- the classes to be added.public void clear()
public void addClass(Clazz clazz)
public void addClass(java.lang.String name, Clazz clazz)
public void removeClass(Clazz clazz)
public Clazz removeClass(java.lang.String className)
public Clazz getClass(java.lang.String className)
null
if the class
with the given name is not in the class pool.className
- a class name (e.g., "java/lang/String").Clazz
. null
if the class pool does not contain a
class with the specified name.public boolean contains(Clazz clazz)
public java.util.Iterator<java.lang.String> classNames()
public java.lang.Iterable<Clazz> classes()
public int size()
public ClassPool refreshedCopy()
public <T> java.util.Map<java.lang.String,T> refreshedKeysCopy(java.util.Map<java.lang.String,T> map)
public <T> java.util.Map<T,java.lang.String> refreshedValuesCopy(java.util.Map<T,java.lang.String> map)
public java.util.Map<Clazz,java.lang.String> reverseMapping()
public void accept(ClassPoolVisitor classPoolVisitor)
public void classesAccept(ClassVisitor classVisitor)
public void classesAcceptAlphabetically(ClassVisitor classVisitor)
public void classesAccept(java.lang.String classNameFilter, ClassVisitor classVisitor)
public void classesAccept(java.util.List classNameFilter, ClassVisitor classVisitor)
public void classesAccept(StringMatcher classNameFilter, ClassVisitor classVisitor)
public void classAccept(java.lang.String className, ClassVisitor classVisitor)