Class FunctionTypeUtils
java.lang.Object
org.springframework.cloud.function.context.catalog.FunctionTypeUtils
Set of utility operations to interrogate function definitions.
- Since:
- 3.0
- Author:
- Oleg Zhurakousky, Andrey Shlykov
-
Method Summary
Modifier and TypeMethodDescriptionstatic TypeconsumerType(Type input) 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 TypediscoverFunctionTypeFromFunctionFactoryMethod(Class<?> clazz, String methodName) Discovers the functionTypebased on the signature of a factory method.static TypeDiscovers the functionTypebased on the signature of a factory method.static TypediscoverFunctionTypeFromFunctionMethod(Method functionMethod) UnlikediscoverFunctionTypeFromFunctionFactoryMethod(Class, String), this method discovers function type from the well known method of Function(apply), Supplier(get) or Consumer(accept).static TypefunctionType(Type input, Type output) static TypegetComponentTypeOfInputType(Type functionType) In the event the input type isParameterizedTypethis method returns its generic type.static TypegetComponentTypeOfOutputType(Type functionType) In the event the output type isParameterizedTypethis method returns its generic type.static TypegetGenericType(Type type) A convenience method identical togetImmediateGenericType(Type, int)for cases when provided 'type' isPublisherorMessage.static TypegetImmediateGenericType(Type type, int index) static intstatic TypegetInputType(Type functionType) Returns input type of function type that represents Function or Consumer.static intstatic 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 booleanstatic booleanisFunction(Type type) static booleanisJsonNode(Type type) static booleanstatic booleanstatic 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 booleanstatic TypesupplierType(Type output)
-
Method Details
-
functionType
-
consumerType
-
supplierType
-
isTypeCollection
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
-
isTypeArray
-
isJsonNode
-
getGenericType
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
Effectively convertsTypewhich could beParameterizedTypeto raw Class (no generics). -
discoverFunctionalMethod
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
-
discoverFunctionTypeFromFunctionFactoryMethod
Discovers the functionTypebased on the signature of a factory method. For example, given the following methodFunction<Message<Person>, Message<String>> uppercase()of class Foo -Type type = discoverFunctionTypeFromFunctionFactoryMethod(Foo.class, "uppercase");- Parameters:
clazz- instance of Class containing the factory methodmethodName- factory method name- Returns:
- type of the function
-
discoverFunctionTypeFromFunctionFactoryMethod
Discovers the functionTypebased on the signature of a factory method. For example, given the following methodFunction<Message<Person>, Message<String>> uppercase()of class Foo -Type type = discoverFunctionTypeFromFunctionFactoryMethod(Foo.class, "uppercase");- Parameters:
method- factory method- Returns:
- type of the function
-
discoverFunctionTypeFromFunctionMethod
UnlikediscoverFunctionTypeFromFunctionFactoryMethod(Class, String), this method discovers function type from the well known method of Function(apply), Supplier(get) or Consumer(accept).- Parameters:
functionMethod- functional method- Returns:
- type of the function
-
getInputCount
-
getOutputCount
-
getComponentTypeOfInputType
In the event the input type isParameterizedTypethis method returns its generic type.- Parameters:
functionType- instance of function type- Returns:
- generic type or input type
-
getComponentTypeOfOutputType
In the event the output type isParameterizedTypethis method returns its generic type.- Parameters:
functionType- instance of function type- Returns:
- generic type or output type
-
getInputType
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
-
discoverBeanDefinitionNameByQualifier
-
getOutputType
-
getImmediateGenericType
-
isPublisher
-
isFlux
-
isCollectionOfMessage
-
isMessage
-
isOutputArray
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
-
isFunction
-
isConsumer
-
isMono
-
isMultipleArgumentType
-