public abstract class ClassSource extends Object
| Constructor and Description |
|---|
ClassSource() |
| Modifier and Type | Method and Description |
|---|---|
protected static String |
append(String a,
String b)
Append to canonical names together.
|
static ClassSource |
attemptLoadFrom(ClassSource... sources)
Retrieve a class source that will attempt lookups in each of the given sources in the order they are in the array, and return the first value that is found.
|
static ClassSource |
empty() |
static ClassSource |
fromClassLoader()
Construct a class source from the default class loader.
|
static ClassSource |
fromClassLoader(ClassLoader loader)
Construct a class source from the given class loader.
|
static ClassSource |
fromMap(Map<String,Class<?>> map)
Construct a class source from a mapping of canonical names and the corresponding classes.
|
static ClassSource |
fromPackage(String packageName)
Construct a class source from the default class loader and package.
|
abstract Class<?> |
loadClass(String canonicalName)
Retrieve a class by name.
|
ClassSource |
retry(ClassSource other)
Retrieve a class source that will retry failed lookups in the given source.
|
ClassSource |
usingPackage(String packageName)
Retrieve a class source that prepends a specific package name to every lookup.
|
public static ClassSource fromClassLoader()
public static ClassSource fromPackage(String packageName)
packageName - - the package that is prepended to every lookup.public static ClassSource fromClassLoader(ClassLoader loader)
loader - - the class loader.public static ClassSource fromMap(Map<String,Class<?>> map)
ClassNotFoundException will be thrown.map - - map of class names and classes.public static ClassSource empty()
public static ClassSource attemptLoadFrom(ClassSource... sources)
sources - - the class sources.public ClassSource retry(ClassSource other)
other - - the other class source.public ClassSource usingPackage(String packageName)
packageName - - the package name to prepend.protected static String append(String a, String b)
a - - the name to the left.b - - the name to the right.public abstract Class<?> loadClass(String canonicalName) throws ClassNotFoundException
canonicalName - - the full canonical name of the class.ClassNotFoundException exception should be thrown.ClassNotFoundException - If the class could not be found.Copyright © 2012–2017 Comphenix and dmulloy2. Licensed under the GNU GPL v2.