Skip to content

[Feature] Mapping hashmap from a field #1218

@DavidWylie

Description

@DavidWylie

When using the mapstruct library for mapping dto objects to domain objects a common problem encountered is the ability to map Hashmaps to object properties.
Existing code to acheive this is to use a custom function which will get a hashmap index from the map and return it.

  @Mapper()
public abstract class OrderMapper {

@Mappings({
        @Mapping(target="id", expression="java( getIdFlag(order, \"id\"))"),
})
abstract Order toDomainOrder order);

}

proposed syntax.

 @Mapper()
public abstract class OrderMapper {

@Mappings({
        @Mapping(target="id", expression="ids[id]"),
})
abstract Order toDomainOrder order);

}

is this something already being investigated or considered?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions