Skip to content

Support referencing a method instead of an expression for a Mapping #3216

@jijoraju

Description

@jijoraju

Use case

The qualified by name can be used without a source param. This will help to create a single method that can be used across the other mapping methods.

e.g.,

@Named("getInstant") default Instant getInstant() { return Instant.now(); }

`@Mapping(target = "addedAt", source = "data", qualifiedByName = "getInstant")`

This has a huge advantage of code reusability.

Generated Code

No response

Possible workarounds

No response

MapStruct Version

1.5.2.Beta2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions