mapstruct / mapstruct/mapstruct

Support a real expression language in Mapping#expression()

Open
#244 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Java
Stars
7.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

There should be support for a real expression language in Mapping#expression():

```
@Mapping(target="foo", source="bar.firstName + ' ' + bar.lastName")
```

Possible candidates are Unified EL or SpEL. The latter allows constructor invocations which would be very useful. The general idea is to translate the given expressions into equivalent Java source code which then is embedded into the generated mapping method. Bot UEL (via JUEL) and SpEL allow to access and traverse the AST of given expressions for that purpose.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Mapping#expression() and review how generated mapping methods currently embed expressions. Compare Unified EL via JUEL and SpEL, including their AST access and constructor-invocation behavior. Done means selecting and implementing an expression-language approach that translates the supplied expression into equivalent Java source in the generated mapping method.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.