org.apache.camel.component.facebook.data
Class FacebookMethodsTypeHelper

java.lang.Object
  extended by org.apache.camel.component.facebook.data.FacebookMethodsTypeHelper

public final class FacebookMethodsTypeHelper
extends Object

Helper class for working with FacebookMethodsType.


Nested Class Summary
static class FacebookMethodsTypeHelper.MatchType
           
 
Method Summary
static Map<String,Class<?>> allArguments()
          Get argument types and names used by all methods.
static String convertToGetMethod(String name)
           
static String convertToSearchMethod(String name)
           
static List<FacebookMethodsType> filterMethods(List<FacebookMethodsType> methods, FacebookMethodsTypeHelper.MatchType matchType, String... argNames)
          Filters a list of methods to those that take the given set of arguments.
static List<Object> getArguments(String name)
          Gets argument types and names for all overloaded methods with the given name.
static List<Object> getArgumentsForNameStyle(String name, FacebookNameStyle style)
          Gets argument types and names for all overloaded methods with the given short form name.
static List<FacebookMethodsType> getCandidateMethods(String name, 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.

static FacebookMethodsType getHighestPriorityMethod(List<FacebookMethodsType> filteredMethods)
           
static Set<String> getMissingProperties(String methodName, FacebookNameStyle nameStyle, Set<String> argNames)
          Get missing properties.
static Class<?> getType(String argName)
          Get the type for the given argument name.
static Object invokeMethod(facebook4j.Facebook facebook, FacebookMethodsType method, Map<String,Object> properties)
          Invokes given method with argument values from given properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCandidateMethods

public static List<FacebookMethodsType> getCandidateMethods(String name,
                                                            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 full method name to lookup
argNames - 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 static List<FacebookMethodsType> filterMethods(List<FacebookMethodsType> methods,
                                                      FacebookMethodsTypeHelper.MatchType matchType,
                                                      String... argNames)
Filters a list of methods to those that take the given set of arguments.

Parameters:
methods - list of methods to filter
matchType - whether the arguments are an exact match, a subset or a super set of method args
argNames - 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 static List<Object> getArguments(String name)
                                 throws IllegalArgumentException
Gets argument types and names for all overloaded methods with the given name.

Parameters:
name - method name, must be a long form (i.e. get*, or search*)
Returns:
list of arguments of the form Class type1, String name1, Class type2, String name2,...
Throws:
IllegalArgumentException

getArgumentsForNameStyle

public static List<Object> getArgumentsForNameStyle(String name,
                                                    FacebookNameStyle style)
                                             throws IllegalArgumentException
Gets argument types and names for all overloaded methods with the given short form name.

Parameters:
name - method name, may be a short form
style - name style
Returns:
list of arguments of the form Class type1, String name1, Class type2, String name2,...
Throws:
IllegalArgumentException

getMissingProperties

public static Set<String> getMissingProperties(String methodName,
                                               FacebookNameStyle nameStyle,
                                               Set<String> argNames)
Get missing properties.

Parameters:
methodName - method name
nameStyle - method name style
argNames - available arguments
Returns:
Set of missing argument names

allArguments

public static Map<String,Class<?>> allArguments()
Get argument types and names used by all methods.

Returns:
map with argument names as keys, and types as values

getType

public static Class<?> getType(String argName)
                        throws IllegalArgumentException
Get the type for the given argument name.

Parameters:
argName - argument name
Returns:
argument type
Throws:
IllegalArgumentException

convertToGetMethod

public static String convertToGetMethod(String name)
                                 throws IllegalArgumentException
Throws:
IllegalArgumentException

convertToSearchMethod

public static String convertToSearchMethod(String name)
                                    throws IllegalArgumentException
Throws:
IllegalArgumentException

getHighestPriorityMethod

public static FacebookMethodsType getHighestPriorityMethod(List<FacebookMethodsType> filteredMethods)

invokeMethod

public static Object invokeMethod(facebook4j.Facebook facebook,
                                  FacebookMethodsType method,
                                  Map<String,Object> properties)
                           throws org.apache.camel.RuntimeCamelException
Invokes given method with argument values from given properties.

Parameters:
facebook - Facebook4J target object for invoke
method - method to invoke
properties - Map of arguments
Returns:
result of method invocation
Throws:
org.apache.camel.RuntimeCamelException - on errors


Apache Camel