I'm trying to map from Protobuf to POJO. Here's the POJO:
public class CreateNodesAllDataDto {
private List<UpsertNodeDto> tables;
private List<UpsertColumnDto> columns;
}
where upsertNodeDto
is the following:
public class UpsertNodeDto {
@NotNull
private String workspaceId;
@NotNull
private String id;
@NotNull
private String name;
}
And here's the Protobuf:
message UpsertNodeAllDataInput {
repeated UpsertTableInput tables = 1;
repeated UpsertColumnInput columns = 2;
}
message UpsertTableInput {
string workspace_id = 1;
string id = 2;
string name = 3;
}
You get the idea.
The problem right now is that MapStruct does not map the repeated
fields in Protobuf because the getters for these fields in the generated Java file is name xxx-list. For example, the way to get tables
from UpsertNodeAllDataInput
is input.getTablesList()
rather than input.getTables()
, and apparently MapStruct does not recognize that.
First of all there's definitely no Protobuf generation issue, because ModelMapper, a similar-purpose package, works in conversion UpsertNodeAllDataInput
and CreateNodesAllDataDto
. It is also not an issue of MapStruct installation since it works for POJO to POJO mapping for me. The problem is only one described above.
I've been looking around for a while and have only found answers on mapping POJO to Protobuf. Things like this don't seem to work.