I would like support for nested properties as sources. For example
data class Computer (
val name : String,
val info : Info,
)
data class Info (
val ean: String,
val buyDate: Instant,
)
data class ComputerDto(
val name: String,
val ean: String
)
@Konverter
interface ComputerMapper{
@Konvert(mappings = [
Mapping(target = "ean", source = "info.ean")
])
fun toDto(source: Computer): ComputerDto
}
The trick is in Mapping(target = "ean", source = "info.ean"). I've often wanted to get a specific property from one of the subproperties, and right now I have a workaround of creating an extra function, like:
@Konverter
interface ComputerMapper {
@Konvert(
mappings = [
Mapping(target = "ean", source = "info"),
],
)
fun toDto(source: Computer): ComputerDto
fun mapEan(source: Info)=source.ean
}
I would like support for nested properties as sources. For example
The trick is in
Mapping(target = "ean", source = "info.ean"). I've often wanted to get a specific property from one of the subproperties, and right now I have a workaround of creating an extra function, like: