public class MethodCall extends Object
Modifier and Type | Field and Description |
---|---|
String |
method |
String |
name |
Class[] |
parameterTypes |
Class |
retType |
Constructor and Description |
---|
MethodCall(String method)
Create a new MethodCall targeted at the specified method.
|
Modifier and Type | Method and Description |
---|---|
MethodCall |
add(boolean value)
Use this to add a boolean parameter.
|
MethodCall |
add(char value)
Use this to add a char parameter.
|
MethodCall |
add(double value)
Use this to add a parameter of type double or float.
|
MethodCall |
add(long value)
Use this to add a parameter of type byte, short, char, int and long.
|
MethodCall |
add(Object obj)
Use this to add an Object or array parameter, or to add a primitive parameter
that is wrapped in Java Wrapper object.
|
Object |
invokeOn(Object obj)
Use this to invoke a method on an object (which should not be null).
|
boolean |
invokeOn(Object obj,
boolean defaultReturn)
Use this to invoke a method on an object (which should not be null).
|
char |
invokeOn(Object obj,
char defaultReturn)
Use this to invoke a method on an object (which should not be null).
|
double |
invokeOn(Object obj,
double defaultReturn)
Use this to invoke a method on an object (which should not be null).
|
long |
invokeOn(Object obj,
long defaultReturn)
Use this to invoke a method on an object (which should not be null).
|
Object |
invokeOn(Object obj,
Object defaultReturn)
Use this to invoke a method on an object (which should not be null).
|
Object |
invokeStatic(Class cls)
Use this to invoke a static method on a Class.
|
Object |
invokeStatic(Class cls,
Object defaultReturn)
Use this to invoke a static method on a Class.
|
MethodCall |
reset()
Clear the parameter list to make it ready for a new
set of parameters.
|
public String method
public String name
public Class[] parameterTypes
public Class retType
public MethodCall(String method)
Standard Java type specifiers are used, specifically.
B - byte, C - char, S - short, I - int, J - long, F - float, D - Double
Z - boolean, V - void (for method types only)
[type-specifier - for an array.
LclassName; - for object (NOTE the ending semi-colon).
For object (L) you should use / instead of . as the package separator.
The format for a method is: method_name(concatenated parameter type specifiers)return_type
There are no separators between the parameter type specifiers. If the the method is void you should use V as the return type.
public MethodCall reset()
public MethodCall add(boolean value)
value
- The boolean parameterIllegalArgumentException
- if the current parameter
is not of a boolean type.public MethodCall add(char value)
value
- The character parameterIllegalArgumentException
- if the current parameter
is not of a char type.public MethodCall add(long value)
value
- The value to add.IllegalArgumentException
- if the current parameter
is not of an integer type.public MethodCall add(double value)
value
- The value to add.IllegalArgumentException
- if the current parameter
is not of a float or double type.public MethodCall add(Object obj)
obj
- the Object to add.public Object invokeStatic(Class cls) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
cls
- the Class to invoke the static method on.NoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.public Object invokeOn(Object obj) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
obj
- the Object to invoke the method on.NoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.public Object invokeStatic(Class cls, Object defaultReturn)
cls
- the Class to invoke the static method on.defaultReturn
- a default value to return in case the
method is not found or any other exception is thrown.NoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.public Object invokeOn(Object obj, Object defaultReturn)
obj
- the Object to invoke the method on.defaultReturn
- a default value to return in case theNoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.public long invokeOn(Object obj, long defaultReturn)
obj
- the Object to invoke the method on.defaultReturn
- a default value to return in case theNoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.public double invokeOn(Object obj, double defaultReturn)
obj
- the Object to invoke the method on.defaultReturn
- a default value to return in case theNoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.public boolean invokeOn(Object obj, boolean defaultReturn)
obj
- the Object to invoke the method on.defaultReturn
- a default value to return in case theNoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.public char invokeOn(Object obj, char defaultReturn)
obj
- the Object to invoke the method on.defaultReturn
- a default value to return in case theNoSuchMethodException
- if the method does not exist.IllegalAccessException
- if the underlying method is inaccessible.InvocationTargetException
- if the underlying method threw an exception.