Skip to content
Discussion options

You must be logged in to vote

Hi @berickus, thanks for the question.

Unfortunatly, mappie has no support for mapping Lists to Maps yet. I will think about an approach to simplify mapping collections to other collections, similar to list to list, and set to set. If you might have any suggestions, they would be appreciated.

Currently, I would write what you need as follows:

data class ObjectA(val application: String, val name: String)

data class ObjectB(val name: String)

object Mapper : ObjectMappie<List<ObjectA>, Map<String, ObjectB>>() {
    override fun map(from: List<ObjectA>) = from.associateBy(ObjectA::name) { ObjectBMapper.map(it) }

    // Or move outside Mapper if it's not only required inside Mapper.
    pri…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by stefankoppier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants