← Back to Kairo Docs|API Reference (Dokka)

Package-level declarations

Types

Link copied to clipboard
sealed class Optional<out T : Any> : OptionalBase<T>

Kairo Optionals can be used to differentiate between missing and null values. This comes in especially handy for RFC 7396 (JSON Merge Patch).

Link copied to clipboard
abstract class OptionalBase<out T : Any>

Common base for Optional and Required. Provides isSpecified and getOrThrow so code can operate on either type generically.

Link copied to clipboard
class OptionalModule : SimpleModule

Jackson module for Optional and Required serialization. Must be registered with KairoJson to use these types.

Link copied to clipboard
sealed class Required<out T : Any> : OptionalBase<T>

Like Optional but without a Null variant. Use when the value must be non-null if present. Useful for required fields in JSON Merge Patch.

Functions

Link copied to clipboard
fun <T : Any> Optional<T>.ifSpecified(block: (T?) -> Unit)

Runs block for Optional.Null and Optional.Value, skips Optional.Missing. The block receives null for the Null variant.

fun <T : Any> Required<T>.ifSpecified(block: (T) -> Unit)
Link copied to clipboard
fun <T : Any, R : Any> Optional<T>.transform(block: (T?) -> R?): Optional<R>

Applies block to the inner value, preserving Optional.Missing state.

fun <T : Any, R : Any> Required<T>.transform(block: (T) -> R): Required<R>

Applies block to the inner value, preserving Required.Missing state.