Class TypeUtils

java.lang.Object
dev.langchain4j.service.TypeUtils

public class TypeUtils extends Object
  • Constructor Details

    • TypeUtils

      public TypeUtils()
  • Method Details

    • getRawClass

      public static Class<?> getRawClass(Type type)
    • typeHasRawClass

      public static boolean typeHasRawClass(Type type, Class<?> rawClass)
    • resolveFirstGenericParameterClass

      public static Class<?> resolveFirstGenericParameterClass(Type returnType)
    • validateReturnTypesAreProperlyParametrized

      public static void validateReturnTypesAreProperlyParametrized(String methodName, Type type)

      Ensures that no wildcard and/or parametrized types are being used as service method return type.

      For example - such (service) method return types will pass:

      • String
      • MyCustomPojo
      • List<MyCustomPojo>
      • Set<MyCustomPojo>
      • Result<String>
      • Result<MyCustomPojo>
      • Result<List<MyCustomPojo>>
      ... and there are few examples that will fail:
      • List<?>
      • Result<?>
      • Result<List<?>>
      • List<T>
      • Result<T>
      • Result<List<T>>
      *
      Parameters:
      methodName - the method name
      type - the return type