mapstruct / mapstruct/mapstruct

mapstruct native support protobuf

Aperta
#3,073 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
7.7k
Fork
1.1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il protobuf map mapping mostrato nel mapper BasicTestMessageMap generato e conferma la UnsupportedOperationException della chiamata putAll basata sul getter. Confronta il codice generato con l’operazione di map del builder richiesta; il lavoro è completato quando i protobuf map mappings funzionano senza quell’eccezione e il comportamento generato previsto è coperto da un test di regressione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
backend-api-design
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.