Package dev.langchain4j.classloading
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends Annotation>
Optional<T> getAnnotation
(Class<?> clazz, Class<T> annotationClass) Retrieves an annotation of the specified type from the given class.<T extends Annotation>
Optional<T> getAnnotation
(Method method, Class<T> annotationClass) Retrieves an annotation of the specified type from the given method.getNonStaticMethodsOnClass
(Class<?> clazz) Retrieves an iterable containing method keys for all non-static methods defined in the specified class.
-
Constructor Details
-
ReflectionBasedClassMetadataProviderFactory
public ReflectionBasedClassMetadataProviderFactory()
-
-
Method Details
-
getAnnotation
Description copied from interface:ClassMetadataProviderFactory
Retrieves an annotation of the specified type from the given method.- Specified by:
getAnnotation
in interfaceClassMetadataProviderFactory<Method>
- Type Parameters:
T
- The type of the annotation to locate, which must extendAnnotation
.- 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 emptyOptional
if the annotation is not present on the specified method.
-
getAnnotation
Description copied from interface:ClassMetadataProviderFactory
Retrieves an annotation of the specified type from the given class.- Specified by:
getAnnotation
in interfaceClassMetadataProviderFactory<Method>
- Type Parameters:
T
- The type of the annotation to locate, which must extendAnnotation
.- 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 emptyOptional
if the annotation is not present on the specified class.
-
getNonStaticMethodsOnClass
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 interfaceClassMetadataProviderFactory<Method>
- Parameters:
clazz
- The class from which to retrieve methods.- Returns:
- An iterable of method keys corresponding to the methods of the specified class.
-