public class MethodCoercions
extends java.lang.Object
| Constructor and Description |
|---|
MethodCoercions() |
| Modifier and Type | Method and Description |
|---|---|
static com.google.common.base.Predicate<java.lang.reflect.Method> |
matchMultiParameterMethod(java.lang.String methodName,
java.util.List<?> arguments)
Returns a predicate that matches a method with the given name, and parameters that
TypeCoercions.tryCoerce(Object, com.google.common.reflect.TypeToken) can process
from the given list of arguments. |
static com.google.common.base.Predicate<java.lang.reflect.Method> |
matchSingleParameterMethod(java.lang.String methodName,
java.lang.Object argument)
Returns a predicate that matches a method with the given name, and a single parameter that
TypeCoercions.tryCoerce(Object, com.google.common.reflect.TypeToken) can process
from the given argument. |
static Maybe<?> |
tryFindAndInvokeBestMatchingMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Object argument)
Tries to find a method with each parameter compatible with (can be coerced to) the corresponding argument, and invokes it.
|
static Maybe<?> |
tryFindAndInvokeMultiParameterMethod(java.lang.Object instance,
java.lang.String methodName,
java.util.List<?> arguments)
Tries to find a multiple-parameter method with each parameter compatible with (can be coerced to) the
corresponding argument, and invokes it.
|
static Maybe<?> |
tryFindAndInvokeSingleParameterMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Object argument)
Tries to find a single-parameter method with a parameter compatible with (can be coerced to) the argument, and
invokes it.
|
public static com.google.common.base.Predicate<java.lang.reflect.Method> matchSingleParameterMethod(java.lang.String methodName,
java.lang.Object argument)
TypeCoercions.tryCoerce(Object, com.google.common.reflect.TypeToken) can process
from the given argument.methodName - name of the methodargument - argument that is intended to be givenpublic static Maybe<?> tryFindAndInvokeSingleParameterMethod(java.lang.Object instance, java.lang.String methodName, java.lang.Object argument)
instance - the object to invoke the method onmethodName - the name of the method to invokeargument - the argument to the method's parameter.Maybe.absent() if method could not be matched.public static com.google.common.base.Predicate<java.lang.reflect.Method> matchMultiParameterMethod(java.lang.String methodName,
java.util.List<?> arguments)
TypeCoercions.tryCoerce(Object, com.google.common.reflect.TypeToken) can process
from the given list of arguments.methodName - name of the methodarguments - arguments that is intended to be givenpublic static Maybe<?> tryFindAndInvokeMultiParameterMethod(java.lang.Object instance, java.lang.String methodName, java.util.List<?> arguments)
instance - the object to invoke the method onmethodName - the name of the method to invokeargument - a list of the arguments to the method's parameters.Maybe.absent() if method could not be matched.public static Maybe<?> tryFindAndInvokeBestMatchingMethod(java.lang.Object instance, java.lang.String methodName, java.lang.Object argument)
instance - the object to invoke the method onmethodName - the name of the method to invokeargument - a list of the arguments to the method's parameters, or a single argument for a single-parameter method.Maybe.absent() if method could not be matched.