Class TypeAllowlist
java.lang.Object
dev.langchain4j.internal.TypeAllowlist
Decides which types may be instantiated while reading JSON that carries type information.
JSON written with type information names the classes to instantiate, so reading it is a way to instantiate whatever the document asks for. An allowlist is what keeps that from being a way to instantiate anything on the classpath.
The decision is expressed here in terms of class names rather than in a JSON library's validator interface, so that every codec asks the same question of the same list.
-
Constructor Summary
ConstructorsConstructorDescriptionStarts with the JDK value types and LangChain4j's own data types, which any document may name. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllowedClass(String className) voidaddAllowedPrefix(String prefix) booleanisAllowedTypeId(String typeId) Whether a type named in the document may be instantiated.booleanisAlwaysAllowedType(Class<?> rawClass) Whether a resolved type is one of the few always permitted regardless of the allowlist: primitives, boxed primitives, strings and enums.
-
Constructor Details
-
TypeAllowlist
public TypeAllowlist()Starts with the JDK value types and LangChain4j's own data types, which any document may name. Everything else is up to the caller.
-
-
Method Details
-
addAllowedPrefix
-
addAllowedClass
-
isAllowedTypeId
Whether a type named in the document may be instantiated. An array type is judged by its element type. -
isAlwaysAllowedType
Whether a resolved type is one of the few always permitted regardless of the allowlist: primitives, boxed primitives, strings and enums.
-