8000 mapstruct native support protobuf · Issue #3073 · mapstruct/mapstruct · GitHub
[go: up one dir, main page]

Skip to content

mapstruct native support protobuf #3073

@digithuman

Description

@digithuman

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<String, String> map = beanMap.getTestStrMap();
            if ( map != null ) {
                basicTestMessageMap.getTestStrMap().putAll( map );
            }
        }

        return basicTestMessageMap.build();
    }

Possible workarounds

No response

MapStruct Version

1.5.3.Final

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0