public final class MethodName extends 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<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.
|
<T> MethodReturnType<T> |
withReturnType(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(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.Copyright © 2007–2016. All rights reserved.