E409 Add support for Java Text Blocks · Issue #2837 · mapstruct/mapstruct · GitHub
[go: up one dir, main page]

Skip to content

Add support for Java Text Blocks #2837

@arnaldop

Description

@arnaldop
  • [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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0