I use kotlin/springboot and I want to use ModelMapper
to map to Data Classes. I want to map Account:balance:Amount:Int
to AccountDto:balance:Float
From :
data class Account(
val id: String,
var balance: Amount
)
data class Amount(var value: Int)
To :
data class AccountDto(
var id: String,
var balance: Float?)
I tried this :
val modelMapper = ModelMapper()
modelMapper.addMappings(object : PropertyMap<Account, AccountDto>() {
override fun configure() {
map(source.balance.value / 100f, destination.balance)
}
})
but I have error like that :
Caused by: org.modelmapper.ConfigurationException: ModelMapper configuration errors:
1) Cannot map final type ....accounts.Account.
2) Cannot map final method ....accounts.Account.getBalance().
3) Cannot map final type ....accounts.Amount.
4) Cannot map final method ....accounts.Amount.getValue().
5) Cannot map final type ....account.dto.AccountDto.
6) Cannot map final method ....account.dto.AccountDto.getBalance().
I have no more idea right now.