Class ReflectionBasedClassMetadataProviderFactory

java.lang.Object
dev.langchain4j.classloading.ReflectionBasedClassMetadataProviderFactory
All Implemented Interfaces:
ClassMetadataProviderFactory<Method>

public final class ReflectionBasedClassMetadataProviderFactory extends Object implements ClassMetadataProviderFactory<Method>
Implementation of the ClassMetadataProviderFactory interface using Java Reflection. This class provides methods to retrieve annotations and method metadata from classes via reflection-based mechanisms.
  • Constructor Details

    • ReflectionBasedClassMetadataProviderFactory

      public ReflectionBasedClassMetadataProviderFactory()
  • Method Details

    • getAnnotation

      public <T extends Annotation> Optional<T> getAnnotation(Method method, Class<T> annotationClass)
      Description copied from interface: ClassMetadataProviderFactory
      Retrieves an annotation of the specified type from the given method.
      Specified by:
      getAnnotation in interface ClassMetadataProviderFactory<Method>
      Type Parameters:
      T - The type of the annotation to locate, which must extend Annotation.
      Parameters:
      method - The method from which the annotation is to be retrieved.
      annotationClass - The class object corresponding to the annotation type to find.
      Returns:
      An Optional containing the located annotation, or an empty Optional if the annotation is not present on the specified method.
    • getAnnotation

      public <T extends Annotation> Optional<T> getAnnotation(Class<?> clazz, Class<T> annotationClass)
      Description copied from interface: ClassMetadataProviderFactory
      Retrieves an annotation of the specified type from the given class.
      Specified by:
      getAnnotation in interface ClassMetadataProviderFactory<Method>
      Type Parameters:
      T - The type of the annotation to locate, which must extend Annotation.
      Parameters:
      clazz - The class from which the annotation is to be retrieved.
      annotationClass - The class object corresponding to the annotation type to find.
      Returns:
      An Optional containing the located annotation, or an empty Optional if the annotation is not present on the specified class.
    • getNonStaticMethodsOnClass

      public Iterable<Method> getNonStaticMethodsOnClass(Class<?> clazz)
      Description copied from interface: ClassMetadataProviderFactory
      Retrieves an iterable containing method keys for all non-static methods defined in the specified class.
      Specified by:
      getNonStaticMethodsOnClass in interface ClassMetadataProviderFactory<Method>
      Parameters:
      clazz - The class from which to retrieve methods.
      Returns:
      An iterable of method keys corresponding to the methods of the specified class.