public class MethodCoercions
extends java.lang.Object
Constructor and Description |
---|
MethodCoercions() |
Modifier and Type | Method and Description |
---|---|
static <any> |
matchMethodByName(java.lang.String methodName)
Returns a predicate that matches a method with the given name.
|
static <any> |
matchMultiParameterMethod(java.util.List<?> arguments)
Returns a predicate that matches a method with parameters that
org.apache.brooklyn.util.core.flags.TypeCoercions#tryCoerce(Object, com.google.common.reflect.TypeToken) can process
from the given list of arguments. |
static <any> |
matchMultiParameterMethod(java.lang.String methodName,
java.util.List<?> arguments)
Returns a predicate that matches a method with the given name, and parameters that
org.apache.brooklyn.util.core.flags.TypeCoercions#tryCoerce(Object, com.google.common.reflect.TypeToken) can process
from the given list of arguments. |
static <any> |
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
org.apache.brooklyn.util.core.flags.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 instanceOrClazz,
java.lang.Iterable<java.lang.reflect.Method> methods,
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<?> |
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 <any> matchSingleParameterMethod(java.lang.String methodName, java.lang.Object argument)
org.apache.brooklyn.util.core.flags.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 <any> matchMultiParameterMethod(java.lang.String methodName, java.util.List<?> arguments)
org.apache.brooklyn.util.core.flags.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 <any> matchMethodByName(java.lang.String methodName)
methodName
- name of the methodpublic static <any> matchMultiParameterMethod(java.util.List<?> arguments)
org.apache.brooklyn.util.core.flags.TypeCoercions#tryCoerce(Object, com.google.common.reflect.TypeToken)
can process
from the given list of arguments.arguments
- arguments that is intended to be givenpublic static Maybe<?> tryFindAndInvokeMultiParameterMethod(java.lang.Object instanceOrClazz, java.lang.Iterable<java.lang.reflect.Method> methods, java.util.List<?> arguments)
instanceOrClazz
- the object or class to invoke the method onmethods
- the methods to choose fromargument
- a list of the arguments to the method's parameters.Maybe.absent()
if method could not be matched.public 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.