Package org.fest.reflect.type
Class TypeLoader
java.lang.Object
org.fest.reflect.type.TypeLoader
Understands loading a class dynamically using a specific
ClassLoader
.- Since:
- 1.1
- Author:
- Alex Ruiz
-
Method Summary
-
Method Details
-
load
Loads the class with the name specified in this type, using this class'ClassLoader
.Example:
Class<?> type =
type
("org.republic.Jedi").withClassLoader
(myClassLoader).load
();- Returns:
- the loaded class.
- Throws:
ReflectionError
- wrapping any error that occurred during class loading.
-
loadAs
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 classPerson
:Class<Person> type =
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:
NullPointerException
- if the given type isnull
.ReflectionError
- wrapping any error that occurred during class loading.
-