ofValueClass

inline fun <V, T : ValueClass<V>> ofValueClass(fallbackName: String = "value", crossinline toString: (V) -> String = { it.toString() }): StringCodec<T>(source)

Creates a StringCodec for a ValueClass wrapper by delegating to Tapik's default string codec and constructing the wrapper through its primary constructor.

This is intended for value classes such as UserId, OrderNumber, or similar wrapper types that expose a single ValueClass.value property.

Return

a StringCodec that round-trips T using its wrapped ValueClass.value.

Parameters

V

wrapped scalar value type used by the ValueClass.

T

API wrapper type encoded and decoded by the returned codec.

fallbackName

name used in codec diagnostics when T's simple name is unavailable.

toString

function that converts the wrapped V into its string representation.

See also

Throws

when T does not expose a primary constructor.