requireBacking

inline fun <B : Any> KpaElement.requireBacking(libraryName: String): B(source)

Unwraps this KpaElement to its native backing value of type B, or throws if this element is not a BackedKpaElement whose backing is of type B.

Intended as the single-expression body of adapter-family toXxxElement() extension functions:

fun KpaElement.toJsonElement(): JsonElement = requireBacking("kxs")

Return

The backing B value.

Parameters

libraryName

A short library name included in the error message (e.g. "kxs" or "yamlkt").

Type Parameters

B

The expected native backing type.

Throws

if this element has no native backing of type B.