mapstruct / mapstruct/mapstruct
mapstruct native support protobuf
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Use case
The reasons are as follows:
1. gRPC use protobuf ,Jakarta EE 10 choise gRPC as Jakarta RPC , . Net Core same choise gRPC.
2. It is a good idea in the near future that protobuf will be selected as the data exchange foundation of heterogeneous platforms for service mash of microservice architecture.
3. MapStruct is not friendly to protobuf. For a long time, it will inevitably generate new components instead of building on the MapStruct foundation. It may introduce technologies similar to ByteBuf to improve the copy efficiency.
4. No configuration is better than complex configuration. Most people choose MapStruct not to learn complex configuration, but to improve efficiency. In complex scenarios, customers write code instead of configuring MapStruct, which seems to go further and further. What is the original intention of the project? Is the goal of the project to solve complex situations through configuration?
I look forward to your reply!
### Generated Code
Bean Map copy to Protobuf Map putAll Error : UnsupportedOperationException.
correct:
`basicTestMessageMap.putAllTestStrMap(map); `
replace
`basicTestMessageMap.getTestStrMap().putAll( map );`
```
@Override
public BasicTestMessageMap toMap(BasicTestBeanMap beanMap) {
if ( beanMap == null ) {
return null;
}
BasicTestMessageMap.Builder basicTestMessageMap = BasicTestMessageMap.newBuilder();
if ( basicTestMessageMap.getTestStrMap() != null ) {
Map map = beanMap.getTestStrMap();
if ( map != null ) {
basicTestMessageMap.getTestStrMap().putAll( map );
}
}
return basicTestMessageMap.build();
}
```
### Possible workarounds
_No response_
### MapStruct Version
1.5.3.Final
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the protobuf map mapping shown in the generated BasicTestMessageMap mapper and confirm the UnsupportedOperationException from the getter-based putAll call. Compare the generated code with the requested builder map operation; done means protobuf map mappings work without that exception and the intended generated behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100