Entity

sealed class Entity<out S : DynoSchema>

Represents a type-safe wrapper over DynoMap that is bound to a specific DynoSchema.

An Entity ensures that all operations on the underlying map conform to the schema's structure, providing compile-time safety and automatic validation during deserialization.

Entities are immutable by default. For mutable operations, use MutableEntity.

Example:

// Define schema
object Person: EntitySchema("person") {
val name by dynoKey<String>()
val age by dynoKey<Int>()
}

// Create entity
val person = Person.new {
name set "Alex"
age set 30
}

// Access values in a type-safe way
println("Name: ${person[Person.name]}, Age: ${person[Person.age]}")

See also

Inheritors

Properties

Link copied to clipboard
val schema: S

Functions

Link copied to clipboard
abstract fun copy(): Entity<S>
Link copied to clipboard
inline fun <S : DynoSchema, R : Any> Entity<S>.select(body: Selector<S, R>.() -> Unit): R

Executes a selection logic over the schema of this Entity, allowing to define multiple conditional branches based on the actual schema type and providing a fallback via Selector.orElse.