- java.lang.Object
-
- org.apache.camel.support.component.ApiMethodHelper<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classApiMethodHelper.MatchType
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Class<?>>allArguments()Returns argument types and names used by all methods.List<ApiMethod>filterMethods(List<? extends ApiMethod> methods, ApiMethodHelper.MatchType matchType)Filters a list of methods to those that take the given set of arguments.List<ApiMethod>filterMethods(List<? extends ApiMethod> methods, ApiMethodHelper.MatchType matchType, Collection<String> argNames)Filters a list of methods to those that take the given set of arguments.Map<String,Set<String>>getAliases()Returns alias map.List<Object>getArguments(String name)Gets argument types and names for all overloaded methods and aliases with the given name.List<ApiMethod>getCandidateMethods(String name)Gets methods that match the given name and arguments.List<ApiMethod>getCandidateMethods(String name, Collection<String> argNames)Gets methods that match the given name and arguments.static ApiMethodgetHighestPriorityMethod(List<? extends ApiMethod> filteredMethods)Set<String>getMissingProperties(String methodName, Set<String> argNames)Get missing properties.List<String>getNullableArguments()Returns argument names that can be set to null if not specified.Class<?>getType(String argName)Get the type for the given argument name.static ObjectinvokeMethod(Object proxy, ApiMethod method, Map<String,Object> properties)Invokes given method with argument values from given properties.
-
-
-
Constructor Detail
-
ApiMethodHelper
public ApiMethodHelper(Class<T> apiMethodEnum, Map<String,String> aliases, List<String> nullableArguments)
Create a helper to work with aApiMethod, using optional method aliases.- Parameters:
apiMethodEnum-ApiMethodenumeration classaliases- Aliases mapped to actual method namesnullableArguments- names of arguments that default to null value
-
-
Method Detail
-
getCandidateMethods
public List<ApiMethod> getCandidateMethods(String name)
Gets methods that match the given name and arguments. Note that the args list is a required subset of arguments for returned methods.- Parameters:
name- case sensitive method name or alias to lookup- Returns:
- non-null unmodifiable list of methods that take all of the given arguments, empty if there is no match
-
getCandidateMethods
public List<ApiMethod> getCandidateMethods(String name, Collection<String> argNames)
Gets methods that match the given name and arguments. Note that the args list is a required subset of arguments for returned methods.- Parameters:
name- case sensitive method name or alias to lookupargNames- unordered required argument names- Returns:
- non-null unmodifiable list of methods that take all of the given arguments, empty if there is no match
-
filterMethods
public List<ApiMethod> filterMethods(List<? extends ApiMethod> methods, ApiMethodHelper.MatchType matchType)
Filters a list of methods to those that take the given set of arguments.- Parameters:
methods- list of methods to filtermatchType- whether the arguments are an exact match, a subset or a super set of method args- Returns:
- methods with arguments that satisfy the match type. For SUPER_SET match, if methods with exact match are found, methods that take a subset are ignored
-
filterMethods
public List<ApiMethod> filterMethods(List<? extends ApiMethod> methods, ApiMethodHelper.MatchType matchType, Collection<String> argNames)
Filters a list of methods to those that take the given set of arguments.- Parameters:
methods- list of methods to filtermatchType- whether the arguments are an exact match, a subset or a super set of method argsargNames- argument names to filter the list- Returns:
- methods with arguments that satisfy the match type. For SUPER_SET match, if methods with exact match are found, methods that take a subset are ignored
-
getArguments
public List<Object> getArguments(String name) throws IllegalArgumentException
Gets argument types and names for all overloaded methods and aliases with the given name.- Parameters:
name- method name, either an exact name or an alias, exact matches are checked first- Returns:
- list of arguments of the form Class type1, String name1, Class type2, String name2,...
- Throws:
IllegalArgumentException
-
getMissingProperties
public Set<String> getMissingProperties(String methodName, Set<String> argNames)
Get missing properties.- Parameters:
methodName- method nameargNames- available arguments- Returns:
- Set of missing argument names
-
getAliases
public Map<String,Set<String>> getAliases()
Returns alias map.- Returns:
- alias names mapped to method names.
-
allArguments
public Map<String,Class<?>> allArguments()
Returns argument types and names used by all methods.- Returns:
- map with argument names as keys, and types as values
-
getNullableArguments
public List<String> getNullableArguments()
Returns argument names that can be set to null if not specified.- Returns:
- list of argument names
-
getType
public Class<?> getType(String argName) throws IllegalArgumentException
Get the type for the given argument name.- Parameters:
argName- argument name- Returns:
- argument type
- Throws:
IllegalArgumentException
-
getHighestPriorityMethod
public static ApiMethod getHighestPriorityMethod(List<? extends ApiMethod> filteredMethods)
-
invokeMethod
public static Object invokeMethod(Object proxy, ApiMethod method, Map<String,Object> properties) throws org.apache.camel.RuntimeCamelException
Invokes given method with argument values from given properties.- Parameters:
proxy- Proxy object for invokemethod- method to invokeproperties- Map of arguments- Returns:
- result of method invocation
- Throws:
org.apache.camel.RuntimeCamelException- on errors
-
-