public final class MethodName
extends java.lang.Object
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();
| Modifier and Type | Method and Description |
|---|---|
Invoker<java.lang.Void> |
in(java.lang.Object target)
Creates a new invoker for a method that takes no parameters and return value
void. |
static MethodName |
startMethodAccess(java.lang.String name)
Creates a new
: the starting point of the fluent interface for accessing methods using Java
Reflection. |
MethodParameterTypes<java.lang.Void> |
withParameterTypes(java.lang.Class<?>... parameterTypes)
Specifies the parameter types of the method to invoke.
|
<T> MethodReturnType<T> |
withReturnType(java.lang.Class<T> type)
Specifies the return type of the method to invoke.
|
<T> MethodReturnTypeRef<T> |
withReturnType(TypeRef<T> type)
Specifies the return type reference of the method to invoke.
|
public static MethodName startMethodAccess(java.lang.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.java.lang.NullPointerException - if the given name is null.java.lang.IllegalArgumentException - if the given name is empty.public <T> MethodReturnType<T> withReturnType(java.lang.Class<T> type)
void.T - the generic type of the method's return type.type - the return type of the method to invoke.java.lang.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.java.lang.NullPointerException - if the given type reference is null.public MethodParameterTypes<java.lang.Void> withParameterTypes(java.lang.Class<?>... parameterTypes)
parameterTypes - the parameter types of the method to invoke.java.lang.NullPointerException - if the array of parameter types is null.public Invoker<java.lang.Void> in(java.lang.Object target)
void.target - the object containing the method to invoke.java.lang.NullPointerException - if the given target is null.Copyright © 2007-2013 FEST (Fixtures for Easy Software Testing). All Rights Reserved.