Skip to content

Enable referencing targets and sources by fields references instead of String #2927

@almogtavor

Description

@almogtavor

I’d like to be able to pass a getter/setter reference to @Mapping instead of strings. The thing is that with Strings we can use IDE features like "Go To Declaration".
I'd like to use Mapstruct this way:

@Mapper
public interface MovieMapper {

     @Mapping( target = my.example.setTitle(), source= their.demo.getTitle())
     GermanRelease toGerman( OriginalRelease movies );
}

Instead of:

@Mapper
public interface MovieMapper {

     @Mapping( target = "title", source= "title")
     GermanRelease toGerman( OriginalRelease movies );
}

In many cases, we won't even need to specify the group, but even when specifying the group for every field, I'm sure lots of people will be glad to use Mapstruct this way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions