Package dev.langchain4j.classinstance
Class ClassInstanceLoader
java.lang.Object
dev.langchain4j.classinstance.ClassInstanceLoader
Utility class for creating and retrieving instances of specified class types.
This class provides a mechanism to delegate instance creation to a factory, if available,
or fallback to direct instantiation using the no-argument constructor.
This is useful in scenarios where dependency injection frameworks or other managed object factories might need to be leveraged for object creation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T
getClassInstance
(Class<T> clazz) Retrieves an instance of the specified class type.
-
Method Details
-
getClassInstance
Retrieves an instance of the specified class type. This method first attempts to obtain the instance through aClassInstanceFactory
, if available. If no factory is present, it creates a new instance of the class using its no-argument constructor.- Type Parameters:
T
- the type of the class- Parameters:
clazz
- the class object representing the type whose instance is to be created- Returns:
- an instance of the specified class type
-