Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Java Text Blocks #2837

Closed
arnaldop opened this issue Apr 30, 2022 · 5 comments · Fixed by #2872
Closed

Add support for Java Text Blocks #2837

arnaldop opened this issue Apr 30, 2022 · 5 comments · Fixed by #2872
Assignees
Milestone

Comments

@arnaldop
Copy link

arnaldop commented Apr 30, 2022

  • [Y] Is this an issue (and hence not a question)?

The following mapping does not work:

    @Mapping(target = "fieldName", expression =
            """
                java(
                    EnumType1.ENUM_VALUE_1 == dto.getValueOfEnum1()
                    ? EnumType2.ENUM_VALUE_2
                    : dto.getValueOfEnum2()
                )    
            """)

The compile-time error is java: Value for expression must be given in the form "java(<EXPRESSION>)"..

It's possible that the problem is at org.mapstruct.ap.internal.model.source.MappingOptions line 40:
private static final Pattern JAVA_EXPRESSION = Pattern.compile( "^java\\((.*)\\)$" );

In theory, this block of code should work:

entity.setFieldName(
                    EnumType1.ENUM_VALUE_1 == dto.getValueOfEnum1()
                    ? EnumType2.ENUM_VALUE_2
                    : dto.getValueOfEnum2());

Perhaps adding Pattern.MULTILINE would work?

@filiphr
Copy link
Member

filiphr commented May 30, 2022

This makes sense @arnaldop.

Perhaps adding Pattern.MULTILINE would work?

I think that this would do it indeed. Would you like to create a PR for this improvement?

@filiphr
Copy link
Member

filiphr commented Jun 5, 2022

@arnaldop, I've had a look at this and Pattern.MULTILINE won't work. The fix was to use the Pattern.DOTALL flag.

There is PR #2872 that adds this functionality

@arnaldop
Copy link
Author

arnaldop commented Jun 6, 2022

@filiphr, thanks for following up.
I'm sorry it took too long to get into it.
I had downloaded the code and built it. I was looking forward to contributing to this great project.
What is the release schedule for a ticket like this?

@filiphr
Copy link
Member

filiphr commented Jun 6, 2022

I'm sorry it took too long to get into it.
I had downloaded the code and built it. I was looking forward to contributing to this great project.

Sorry, I didn't realize that you wanted to do it. I was going through the issues for 1.6 and wanted to do some of the easier ones.

If you are interested in contributing perhaps you can look at some of the other "good first issue" issues. e.g. #2730. Or if you have some other ideas feel free to offer them. You could also contribute to the IntelliJ plugin by working on mapstruct/mapstruct-idea#98.

What is the release schedule for a ticket like this?

We don't really have a fixed release schedule. Usually something like this would go into the next release, e.g. 1.6. Considering that we just released 1.5 it might take a while. We will discuss it in the team to see if we can do another release (1.5.2) that would include this.

@filiphr
Copy link
Member

filiphr commented Jun 6, 2022

We are planning to do a quick 1.6 beta release, so we will include this in that one.

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

Successfully merging a pull request may close this issue.

2 participants