Class FunctionTypeUtils
- java.lang.Object
-
- org.springframework.cloud.function.context.catalog.FunctionTypeUtils
-
public final class FunctionTypeUtils extends Object
Set of utility operations to interrogate function definitions.- Since:
- 3.0
- Author:
- Oleg Zhurakousky, Andrey Shlykov
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringdiscoverBeanDefinitionNameByQualifier(org.springframework.beans.factory.ListableBeanFactory beanFactory, String qualifier)static MethoddiscoverFunctionalMethod(Class<?> pojoFunctionClass)Will attempt to discover functional methods on the class.static TypediscoverFunctionType(Object function, String functionName, org.springframework.context.support.GenericApplicationContext applicationContext)static TypediscoverFunctionTypeFromClass(Class<?> functionalClass)static TypediscoverFunctionTypeFromFunctionMethod(Method functionMethod)static TypegetGenericType(Type type)A convenience method identical togetImmediateGenericType(Type, int)for cases when provided 'type' isPublisherorMessage.static TypegetImmediateGenericType(Type type, int index)static intgetInputCount(Type functionType)static TypegetInputType(Type functionType)Returns input type of function type that represents Function or Consumer.static intgetOutputCount(Type functionType)static TypegetOutputType(Type functionType)static Class<?>getRawType(Type type)Effectively convertsTypewhich could beParameterizedTypeto raw Class (no generics).static booleanisCollectionOfMessage(Type type)static booleanisConsumer(Type type)static booleanisFlux(Type type)static booleanisFunction(Type type)static booleanisJsonNode(Type type)static booleanisMessage(Type type)static booleanisMono(Type type)static booleanisMultipleArgumentType(Type type)static booleanisOutputArray(Type functionType)Determines if input argument to a Function is an array.static booleanisPublisher(Type type)static booleanisSupplier(Type type)static booleanisTypeArray(Type type)static booleanisTypeCollection(Type type)Will return 'true' if the provided type is aCollectiontype.static booleanisTypeMap(Type type)
-
-
-
Method Detail
-
isTypeCollection
public static boolean isTypeCollection(Type type)
Will return 'true' if the provided type is aCollectiontype. This also includes collections wrapped inMessage. For example, If provided type isMessage<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 togetImmediateGenericType(Type, int)for cases when provided 'type' isPublisherorMessage.- Parameters:
type- type to interrogate- Returns:
- generic type if possible otherwise the same type as provided
-
getRawType
public static Class<?> getRawType(Type type)
Effectively convertsTypewhich could beParameterizedTypeto raw Class (no generics).
-
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 (seeFunctionalInterface)- 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)
-
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)
-
-