public class Reflector extends Object
This is orders of magnitude faster than using reflection directly.
For example, to access a private method on some class Foo, declare an accessor
interface:
class Foo {
private String getName() { ... }
}
@ForType(Foo.class)
interface _Foo_ {
String getName();
}
reflector(_Foo_.class, new Foo()).getName();
| Constructor | Description |
|---|---|
Reflector() |
| Modifier and Type | Method | Description |
|---|---|---|
static <T> T |
reflector(Class<T> iClass) |
Returns an object which provides accessors for invoking otherwise inaccessible static methods
and fields.
|
static <T> T |
reflector(Class<T> iClass,
Object target) |
Returns an object which provides accessors for invoking otherwise inaccessible methods and
fields.
|
public static <T> T reflector(Class<T> iClass)
iClass - an interface with methods matching private methods on the target