Kotlin How to use java streams .map() in kotlin to map a different object response

some quick prototyping

    details  = acctBal
                     .filter{ f -> f.getBalType() != null }
                     .map { it -> mapToProductDetail (it) }

you can have a look here


Thanks to @Hakob Hakobyan for pointing in the right direction,

I left my solution like this:

fun mapRs(rs: AthProductResponse): BalanceByAccountRs {
    val res = rs.getPartyAcctRelRec();
    val balances: List<AcctBal> = res.getAcctBals();
    val account = Account(res.getPartyAcctRelInfo().depAcctId.acctId, res.getPartyAcctRelInfo().depAcctId.acctType)
    var balanceList: List<BalanceMap> = balances
        .filter { f -> f.getDesc() != null }
        .map { it -> mapToProductDetail(it) }
        .toList()
    return BalanceByAccountRs(account, balanceList)
}

fun mapToProductDetail(bal: AcctBal): BalanceMap {
    var propertyValue: Long = 0L;
    if(bal.getExpDt() != null) {
        propertyValue = Timestamp.valueOf(bal.getExpDt()).getTime()
    } else {
        propertyValue = bal.getCurAmt().getAmt().toLong()
    }
    return BalanceMap(bal.getDesc(), propertyValue)
}

Just in case someone is going through the same. Happy coding