r01f.reflection.fluent
Class TypeInvoker
java.lang.Object
r01f.reflection.fluent.TypeInvoker
public final class TypeInvoker
- extends java.lang.Object
Class Loading using a specific ClassLoader.
|
Constructor Summary |
private |
TypeInvoker(java.lang.String className,
java.lang.ClassLoader classLoader)
Constructor |
|
Method Summary |
private java.lang.String |
_composeUnableToLoadClassMessage(java.lang.Class<?> asType)
|
private java.lang.Class<?> |
_loadType()
|
java.lang.Class<?> |
load()
Loads the class with the name specified in this type, using this class' ClassLoader. |
<T> java.lang.Class<? extends T> |
|
loadAs(java.lang.Class<T> type)
Loads the class with the name specified in this type, as the given type, using this class' ClassLoader. |
(package private) static TypeInvoker |
newLoader(java.lang.String className,
java.lang.ClassLoader classLoader)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_className
private final java.lang.String _className
_classLoader
private final java.lang.ClassLoader _classLoader
TypeInvoker
private TypeInvoker(java.lang.String className,
java.lang.ClassLoader classLoader)
- Constructor
- Parameters:
className - classLoader -
newLoader
static TypeInvoker newLoader(java.lang.String className,
java.lang.ClassLoader classLoader)
load
public java.lang.Class<?> load()
- Loads the class with the name specified in this type, using this class'
ClassLoader.
Example:
Class> type = Reflection.type("org.republic.Jedi").withClassLoader(myClassLoader).load();
- Returns:
- the loaded class.
- Throws:
ReflectionError - wrapping any error that occurred during class loading.
loadAs
public <T> java.lang.Class<? extends T> loadAs(java.lang.Class<T> type)
- Loads the class with the name specified in this type, as the given type, using this class'
ClassLoader.
The following example shows how to use this method.
Let's assume that we have the class Jedi that extends the class Person:
Class type = Reflection.type("org.republic.Jedi").withClassLoader(myClassLoader).loadAs(Person.class);
- Type Parameters:
T - the generic type of the type.- Parameters:
type - the given type.
- Returns:
- the loaded class.
- Throws:
java.lang.NullPointerException - if the given type is null.
ReflectionError - wrapping any error that occurred during class loading.
_loadType
private java.lang.Class<?> _loadType()
throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
_composeUnableToLoadClassMessage
private java.lang.String _composeUnableToLoadClassMessage(java.lang.Class<?> asType)