Class PolymorphicTypes
java.lang.Object
dev.langchain4j.internal.PolymorphicTypes
Detection and naming for polymorphic base types — sealed interfaces / classes (no annotations
needed) and types annotated with Jackson's
JsonSubTypes. Used by both schema generation
and the Jackson polymorphic-dispatch hook for sealed types.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault discriminator property name when@JsonTypeInfois not configured. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdiscriminatorPropertyName(Class<?> baseType) Discriminator property name.static StringdiscriminatorValue(Class<?> baseType, Class<?> subtype) Discriminator value for a subtype.findConcreteSubtypes(Class<?> type) Concrete (instantiable) subtypes fortype.static booleanisPolymorphic(Class<?> type) Returnstrueiftypeis a polymorphic base — sealed, or annotated withJsonSubTypes— and has at least one concrete subtype discoverable by langchain4j.static voidverifyJsonTypeInfoIsSupported(Class<?> baseType) Verifies that the@JsonTypeInfoconfiguration onbaseType(if present) uses settings supported by langchain4j.
-
Field Details
-
DEFAULT_DISCRIMINATOR_PROPERTY
Default discriminator property name when@JsonTypeInfois not configured.- See Also:
-
-
Method Details
-
isPolymorphic
Returnstrueiftypeis a polymorphic base — sealed, or annotated withJsonSubTypes— and has at least one concrete subtype discoverable by langchain4j. -
findConcreteSubtypes
-
discriminatorPropertyName
Discriminator property name. Honors@JsonTypeInfo(property=...)when explicit; otherwise"@type"for@JsonTypeInfo-annotated bases (Jackson's default) andDEFAULT_DISCRIMINATOR_PROPERTYotherwise. -
discriminatorValue
Discriminator value for a subtype. Resolution order:@JsonSubTypes.Type(name=...)on the base →@JsonTypeNameon the subtype →Class.getSimpleName(). -
verifyJsonTypeInfoIsSupported
Verifies that the@JsonTypeInfoconfiguration onbaseType(if present) uses settings supported by langchain4j. Throws otherwise so the user gets a clear failure at schema-generation time rather than a silent mismatch.Supported
use:Id.NAME,Id.SIMPLE_NAME.
Supportedinclude:As.PROPERTY,As.EXISTING_PROPERTY.
-