Introspections

Utility object for annotation-based introspection, providing methods to process annotations for descriptions, ignore markers, and name overrides.

This object provides a configurable mechanism for recognizing annotations from multiple frameworks (kotlinx-schema, Jackson, LangChain4j, Koog, kotlinx.serialization, etc.) Configuration is loaded from kotlinx-schema.properties on the classpath.

Annotation name matching

Annotation names are matched in two ways depending on the configured name format:

  • Simple names (no dots): Matched case-insensitively against the annotation's simple name. Example: "Description" matches @Description, @description, @DESCRIPTION.

  • Fully qualified names (contains dots): Matched case-sensitively against the annotation's qualified name. Example: "kotlinx.serialization.SerialName" matches only @kotlinx.serialization.SerialName, not a different @SerialName from another package.

Configuration

The annotation detection behavior is controlled by properties in kotlinx-schema.properties:

  • introspector.annotations.description.names: Comma-separated list of annotation names to recognize as description providers (e.g., "Description,LLMDescription,P")

  • introspector.annotations.description.attributes: Comma-separated list of annotation parameter names that contain description text (e.g., "value,description")

  • introspector.annotations.ignore.names: Comma-separated list of annotation names to recognize as ignore markers (e.g., "SchemaIgnore,JsonIgnoreType")

  • introspector.annotations.name.names: Comma-separated list of annotation names to recognize as name-override providers (e.g., "kotlinx.serialization.SerialName")

  • introspector.annotations.name.attributes: Comma-separated list of annotation parameter names that contain name-override text (e.g., "value")

Customizing Configuration

To add support for custom annotations, create kotlinx-schema.properties in your project's src/main/resources/ directory (or src/commonMain/resources/ for multiplatform projects):

introspector.annotations.description.names=Description,MyCustomDescription
introspector.annotations.description.attributes=value,description,text

Your project's properties file will take precedence over the library's default configuration.

See also

Functions

Link copied to clipboard
fun getDescriptionFromAnnotation(simpleName: String, qualifiedName: String?, annotationArguments: List<Pair<String, Any?>>): String?

Extracts the description text from an annotation if it matches a recognized description annotation.

Link copied to clipboard
fun getNameOverride(simpleName: String, qualifiedName: String?, annotationArguments: List<Pair<String, Any?>>): String?

Extracts the name-override value from an annotation if it matches a recognized name-override annotation (e.g., @SerialName).

Link copied to clipboard
fun isIgnoreAnnotation(simpleName: String, qualifiedName: String? = null): Boolean

Checks whether the given annotation is recognized as an ignore marker.