Class FunctionTypeUtils


  • public final class FunctionTypeUtils
    extends Object
    Set of utility operations to interrogate function definitions.
    Since:
    3.0
    Author:
    Oleg Zhurakousky, Andrey Shlykov
    • Method Detail

      • isTypeCollection

        public static boolean isTypeCollection​(Type type)
        Will return 'true' if the provided type is a Collection type. This also includes collections wrapped in Message. For example, If provided type is Message<List<Foo>> this operation will return 'true'.
        Parameters:
        type - type to interrogate
        Returns:
        'true' if this type represents a Collection. Otherwise 'false'.
      • isTypeMap

        public static boolean isTypeMap​(Type type)
      • isTypeArray

        public static boolean isTypeArray​(Type type)
      • isJsonNode

        public static boolean isJsonNode​(Type type)
      • getGenericType

        public static Type getGenericType​(Type type)
        A convenience method identical to getImmediateGenericType(Type, int) for cases when provided 'type' is Publisher or Message.
        Parameters:
        type - type to interrogate
        Returns:
        generic type if possible otherwise the same type as provided
      • getRawType

        public static Class<?> getRawType​(Type type)
        Effectively converts Type which could be ParameterizedType to raw Class (no generics).
        Parameters:
        type - actual Type instance
        Returns:
        instance of Class as raw representation of the provided Type
      • discoverFunctionalMethod

        public static Method discoverFunctionalMethod​(Class<?> pojoFunctionClass)
        Will attempt to discover functional methods on the class. It's applicable for POJOs as well as functional classes in `java.util.function` package. For the later the names of the methods are well known (`apply`, `accept` and `get`). For the former it will attempt to discover a single method following semantics described in (see FunctionalInterface)
        Parameters:
        pojoFunctionClass - the class to introspect
        Returns:
        functional method
      • discoverFunctionTypeFromClass

        public static Type discoverFunctionTypeFromClass​(Class<?> functionalClass)
      • discoverFunctionTypeFromFunctionMethod

        public static Type discoverFunctionTypeFromFunctionMethod​(Method functionMethod)
      • getInputCount

        public static int getInputCount​(Type functionType)
      • getOutputCount

        public static int getOutputCount​(Type functionType)
      • getInputType

        public static Type getInputType​(Type functionType)
        Returns input type of function type that represents Function or Consumer.
        Parameters:
        functionType - the Type of Function or Consumer
        Returns:
        the input type as Type
      • discoverFunctionType

        public static Type discoverFunctionType​(Object function,
                                                String functionName,
                                                org.springframework.context.support.GenericApplicationContext applicationContext)
      • discoverBeanDefinitionNameByQualifier

        public static String discoverBeanDefinitionNameByQualifier​(org.springframework.beans.factory.ListableBeanFactory beanFactory,
                                                                   String qualifier)
      • getOutputType

        public static Type getOutputType​(Type functionType)
      • getImmediateGenericType

        public static Type getImmediateGenericType​(Type type,
                                                   int index)
      • isPublisher

        public static boolean isPublisher​(Type type)
      • isFlux

        public static boolean isFlux​(Type type)
      • isCollectionOfMessage

        public static boolean isCollectionOfMessage​(Type type)
      • isMessage

        public static boolean isMessage​(Type type)
      • isOutputArray

        public static boolean isOutputArray​(Type functionType)
        Determines if input argument to a Function is an array.
        Parameters:
        functionType - the function type
        Returns:
        true if input type is an array, otherwise false
      • isSupplier

        public static boolean isSupplier​(Type type)
      • isFunction

        public static boolean isFunction​(Type type)
      • isConsumer

        public static boolean isConsumer​(Type type)
      • isMono

        public static boolean isMono​(Type type)
      • isMultipleArgumentType

        public static boolean isMultipleArgumentType​(Type type)