Skip to content

Reusing mapping method with more than one parameter #1315

Description

@anticlockwise

Hi all, so I have the following mapping method:

@Mapper
public interface DomainDtoMapper {
  @Mappings({
    @Mapping(target = "targetA", source = "objA.sourceA"),
    @Mapping(target = "targetB", source="objB.sourceB")
  })
  public DomainDto map(final DomainObjA objA, final DomainObjB objB);
}

which works perfectly if it was just used to map directly from DomainObjA and DomainObjB to DomainDto. However, when DomainDto is used by another class DomainDtoWrapper, how would I go writing DomainDtoWrapper's mapper class so that I can reuse the mapper I wrote for DomainDto? For example, I would like to be able to write

@Mapper(uses = { DomainDtoMapper.class })
public interface DomainDtoWrapper {
  @Mapping(target = "domainDto", source = { "objA", "objB" })
  public DomainDtoWrapper map(final DomainObjA objA, final DomainObjB objB);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions