Class TypeResolverHelper

java.lang.Object
org.springframework.ai.tool.resolution.TypeResolverHelper

public final class TypeResolverHelper extends Object
A utility class that provides methods for resolving types and classes related to functions.
Author:
Christian Tzolov, Sebastien Dekeuze
  • Method Details

    • getConsumerInputClass

      public static Class<?> getConsumerInputClass(Class<? extends Consumer<?>> consumerClass)
      Returns the input class of a given Consumer class.
      Parameters:
      consumerClass - The consumer class.
      Returns:
      The input class of the consumer.
    • getBiFunctionInputClass

      public static Class<?> getBiFunctionInputClass(Class<? extends BiFunction<?,?,?>> biFunctionClass)
      Returns the input class of a given function class.
      Parameters:
      biFunctionClass - The function class.
      Returns:
      The input class of the function.
    • getFunctionInputClass

      public static Class<?> getFunctionInputClass(Class<? extends Function<?,?>> functionClass)
      Returns the input class of a given function class.
      Parameters:
      functionClass - The function class.
      Returns:
      The input class of the function.
    • getFunctionOutputClass

      public static Class<?> getFunctionOutputClass(Class<? extends Function<?,?>> functionClass)
      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 with BeanDefinition.getResolvableType() or by resolving the factory method (duplicating ConstructorResolver#resolveFactoryMethodIfPossible logic 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