- [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?