I'm trying to map some POJOs from Java to Protobuf (proto3). Some of them contain Lists. While mapping lists with POJOs (for example List) is no problem, I'm getting a UnsupportedOperationException.
Example with List<Product>
(this works corrctly):
ProductProtobuf.Builder map(Product product);
@Mapping(target = "productsList", source = "products")
ResponseProtobuf.Builder map(Response response);
Example with List<String>
(this doesn't work):
@Mapping(target = "usersList", source = "users")
ResponseProtobuf.Builder map(Response response);
Additionally, I have some Mapper for builder:
public ResponseProtobuf.Builder responseBuilder() {
return ResponseProtobuf.newBuilder();
}
public ProductProtobuf build(ProductProtobuf.Builder builder) {
return builder.build();
}
@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
The problem occures ONLY for List<String> because MapStruct would create an object of type ProtocolStringList (instead of String<List>), which is an interface and therefore can't be used. – Quits