com.puppycrawl.tools.checkstyle.checks
Class ClassResolver
public class ClassResolver
Utility class to resolve a class name to an actual class. Note that loaded
classes are not initialized.
Limitations: this does not handle inner classes very well.
ClassResolver(ClassLoader aLoader, String aPkg, Set aImports)- Creates a new
ClassResolver instance.
|
boolean | isLoadable(String aName)
|
Class | resolve(String aName, String aCurrentClass)- Attempts to resolve the Class for a specified name.
|
Class | safeLoad(String aName)- Will load a specified class is such a way that it will NOT be
initialised.
|
ClassResolver
public ClassResolver(ClassLoader aLoader,
String aPkg,
Set aImports) Creates a new ClassResolver instance.
aLoader - the ClassLoader to load classes with.aPkg - the name of the package the class may belong toaImports - set of imports to check if the class belongs to
isLoadable
public boolean isLoadable(String aName)
aName - name of the class to check
- whether a specified class is loadable with safeLoad().
resolve
public Class resolve(String aName,
String aCurrentClass)
throws ClassNotFoundException Attempts to resolve the Class for a specified name. The algorithm is
to check:
- fully qualified name
- explicit imports
- enclosing package
- star imports
aName - name of the class to resolveaCurrentClass - name of current class (for inner classes).
safeLoad
public Class safeLoad(String aName)
throws ClassNotFoundException Will load a specified class is such a way that it will NOT be
initialised.
aName - name of the class to load
- the
Class for the specified class