Class TypeResolverHelper
java.lang.Object
org.springframework.ai.tool.resolution.TypeResolverHelper
A utility class that provides methods for resolving types and classes related to
functions.
- Author:
- Christian Tzolov, Sebastien Dekeuze
-
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?>getBiFunctionArgumentClass(Class<? extends BiFunction<?, ?, ?>> biFunctionClass, int argumentIndex) Retrieves the class of a specific argument in a given function class.static Class<?>getBiFunctionInputClass(Class<? extends BiFunction<?, ?, ?>> biFunctionClass) Returns the input class of a given function class.static Class<?>getConsumerInputClass(Class<? extends Consumer<?>> consumerClass) Returns the input class of a given Consumer class.static Class<?>getFunctionArgumentClass(Class<? extends Function<?, ?>> functionClass, int argumentIndex) Retrieves the class of a specific argument in a given function class.static org.springframework.core.ResolvableTypegetFunctionArgumentType(org.springframework.core.ResolvableType functionType, int argumentIndex) Retrieves the type of a specific argument in a given function class.static Class<?>getFunctionInputClass(Class<? extends Function<?, ?>> functionClass) Returns the input class of a given function class.static Class<?>getFunctionOutputClass(Class<? extends Function<?, ?>> functionClass) Returns the output class of a given function class.static org.springframework.core.ResolvableTyperesolveBeanType(org.springframework.context.support.GenericApplicationContext applicationContext, String beanName) Resolve bean type, either directly withBeanDefinition.getResolvableType()or by resolving the factory method (duplicatingConstructorResolver#resolveFactoryMethodIfPossiblelogic as it is not public).
-
Method Details
-
getConsumerInputClass
Returns the input class of a given Consumer class.- Parameters:
consumerClass- The consumer class.- Returns:
- The input class of the consumer.
-
getBiFunctionInputClass
Returns the input class of a given function class.- Parameters:
biFunctionClass- The function class.- Returns:
- The input class of the function.
-
getFunctionInputClass
Returns the input class of a given function class.- Parameters:
functionClass- The function class.- Returns:
- The input class of the function.
-
getFunctionOutputClass
Returns the output class of a given function class.- Parameters:
functionClass- The function class.- Returns:
- The output class of the function.
-
getFunctionArgumentClass
public static Class<?> getFunctionArgumentClass(Class<? extends Function<?, ?>> functionClass, int argumentIndex) Retrieves the class of a specific argument in a given function class.- Parameters:
functionClass- The function class.argumentIndex- The index of the argument whose class should be retrieved.- Returns:
- The class of the specified function argument.
-
getBiFunctionArgumentClass
public static Class<?> getBiFunctionArgumentClass(Class<? extends BiFunction<?, ?, ?>> biFunctionClass, int argumentIndex) Retrieves the class of a specific argument in a given function class.- Parameters:
biFunctionClass- The function class.argumentIndex- The index of the argument whose class should be retrieved.- Returns:
- The class of the specified function argument.
-
resolveBeanType
public static org.springframework.core.ResolvableType resolveBeanType(org.springframework.context.support.GenericApplicationContext applicationContext, String beanName) Resolve bean type, either directly withBeanDefinition.getResolvableType()or by resolving the factory method (duplicatingConstructorResolver#resolveFactoryMethodIfPossiblelogic as it is not public).- Parameters:
applicationContext- The application context.beanName- The name of the bean to find a definition for.- Returns:
- The resolved type.
- Throws:
IllegalArgumentException- if the type of the bean definition is not resolvable.
-
getFunctionArgumentType
public static org.springframework.core.ResolvableType getFunctionArgumentType(org.springframework.core.ResolvableType functionType, int argumentIndex) Retrieves the type of a specific argument in a given function class.- Parameters:
functionType- The function type.argumentIndex- The index of the argument whose type should be retrieved.- Returns:
- The type of the specified function argument.
- Throws:
IllegalArgumentException- if functionType is not a supported type
-