ParameterConverterRegistry

Holds ParameterConverters and runs a value through the first one that claims it.

Unlike the result side, converters are kept in one flat list rather than indexed by class, since a parameter converter decides for itself what it accepts. The list is searched most-recent-first and then handed on to the parent registry, so a registration overrides an earlier one without removing it.

Registration is thread-safe and reads are lock-free: adding a converter replaces the list rather than mutating it, so a lookup already in flight completes against the list it started with.

Parameters

parent

The registry to fall back to when nothing here claims a value.

Constructors

Link copied to clipboard
constructor(parent: ParameterConverterRegistry? = null)

Functions

Link copied to clipboard
fun addConverter(converter: ParameterConverter<*>)

Registers a converter ahead of everything already here.

Link copied to clipboard
fun convert(source: Any, expectedOid: Int, context: SerializationContext): Any

Runs a value through the first converter that claims it.

Link copied to clipboard
fun findConverter(source: Any, expectedOid: Int, context: SerializationContext): ParameterConverter<Any>?

Finds the converter that would claim a value, without converting anything.

Link copied to clipboard
fun findConverterByClass(sourceClass: KClass<*>, expectedOid: Int, context: SerializationContext): ParameterConverter<Any>?

Same as findConverter, keyed on a class rather than an instance.