I am trying to use mapstruct to map my DTO to protobuf generated class. This class contains a map but this cause an Exception:
java.lang.UnsupportedOperationException
at java.util.Collections$UnmodifiableMap.putAll(Collections.java:1463)
I am not sure how to bypass this.
this is my mapper function
@Mappings({
@Mapping(target = "profiles", source = "profiles"),
MyClassMessage.Builder convertToBuilder(MyClassDto myClassDto);
it generate this code
if ( builder.getProfiles() != null ) {
Map<String, Object> map = stringInterpreterProfileMapToStringInterpreterProfileMessageMap( interpreterSettingDto.getProfiles() );
if ( map != null ) {
builder.getProfiles().putAll( map ); // <-- this cause the exception
}
}
But i think it should be something like this instread
if ( builder.getProfiles() != null ) {
Map<String, Object> map = stringInterpreterProfileMapToStringInterpreterProfileMessageMap( interpreterSettingDto.getProfiles() );
if ( map != null ) {
builder.putAllProfiles( map );
}
}
How should i tell mapstruct to do that way?