mapper

Parameters

mapper

Optional, custom mapper implementation to use instead of reflection. Must implement PgCompositeMapper.

Examples

// Example 1: Using default naming convention and reflection
@PgComposite
data class UserInfo(val id: Int, val username: String)

// Example 2: Explicit type name and custom mapper
@PgComposite(name = "stats_type", mapper = StatsMapper::class)
data class Stats(val strength: Int, val agility: Int)

object StatsMapper : PgCompositeMapper<Stats> {
override fun fromMap(map: Map<String, Any?>) = Stats(
strength = map["strength"] as Int,
agility = map["agility"] as Int
)
override fun toMap(obj: Stats) = mapOf(
"strength" to obj.strength,
"agility" to obj.agility
)
}