MutableEntity

class MutableEntity<out S : DynoSchema> : Entity<S>

A mutable version of Entity that allows in-place modifications of the underlying map.

Unlike Entity, MutableEntity implements MutableDynoMap, enabling runtime modifications while still maintaining schema-bound type safety.

Example:

val person = MutableEntity(Person)
person[Person.name] = "Alex"
person[Person.age] = 30

// Or using put
person.put(Person.name, "Alex")

Note: Mutations do not automatically trigger schema validation. Ensure all required fields are present before serialization or further processing.

See also

MutableDynoMap

Constructors

Link copied to clipboard
constructor(schema: S)
constructor(schema: S, capacity: Int)
constructor(schema: S, other: <Error class: unknown class><SchemaProperty<S, *>>, readSafety: <Error class: unknown class> = other.unsafeCast<DynoMapImpl>().readSafety)
constructor(schema: S, data: MutableMap<Any, Any>?, json: Json?, readSafety: <Error class: unknown class> = DynoReadSafety.SYNCHRONIZED)

Properties

Link copied to clipboard
val schema: S

Functions

Link copied to clipboard
open override fun copy(): MutableEntity<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.