|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.reflect.method.MethodName
public final class MethodName
Understands the name of a method to invoke using Java Reflection.
The following is an example of proper usage of this class:
// Equivalent to call 'person.setName("Luke")'
method("setName").withParameterTypes(String.class)
.in(person)
.invoke("Luke");
// Equivalent to call 'person.concentrate()'
method("concentrate").in(person).invoke();
// Equivalent to call 'person.getName()'
String name = method("getName").withReturnType(String.class)
.in(person)
.invoke();
// Equivalent to call 'jedi.getPowers()'
List<String> powers = method("getPowers").withReturnType(new TypeRef<List<String>>() {})
.in(person)
.invoke();
| Method Summary | ||
|---|---|---|
Invoker<Void> |
in(Object target)
Creates a new invoker for a method that takes no parameters and return value void. |
|
static MethodName |
startMethodAccess(String name)
Creates a new : the starting point of the fluent interface for accessing methods
using Java Reflection. |
|
MethodParameterTypes<Void> |
withParameterTypes(Class<?>... parameterTypes)
Specifies the parameter types of the method to invoke. |
|
|
withReturnType(Class<T> type)
Specifies the return type of the method to invoke. |
|
|
withReturnType(TypeRef<T> type)
Specifies the return type reference of the method to invoke. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static MethodName startMethodAccess(String name)
MethodName: the starting point of the fluent interface for accessing methods
using Java Reflection.
name - the name of the method to invoke using Java Reflection.
MethodName.
NullPointerException - if the given name is null.
IllegalArgumentException - if the given name is empty.public <T> MethodReturnType<T> withReturnType(Class<T> type)
void.
T - the generic type of the method's return type.type - the return type of the method to invoke.
NullPointerException - if the given type is null.public <T> MethodReturnTypeRef<T> withReturnType(TypeRef<T> type)
void.
T - the generic type of the method's return type.type - the return type reference of the method to invoke.
NullPointerException - if the given type reference is null.public MethodParameterTypes<Void> withParameterTypes(Class<?>... parameterTypes)
parameterTypes - the parameter types of the method to invoke.
NullPointerException - if the array of parameter types is null.public Invoker<Void> in(Object target)
void.
target - the object containing the method to invoke.
NullPointerException - if the given target is null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||