Unexpected warning: ''.'' should not be used as a source
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia riproducendo l'avviso con l'esempio FooMapper e verifica come il MapStruct IntelliJ plugin gestisce i valori di @Mapping il cui source è ".". Confronta questo comportamento con il supporto documentato da MapStruct per questa forma di source; il lavoro è completato quando il mapping valido non genera più un avviso errato oppure il motivo dell'avviso è stato stabilito chiaramente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I often have a use-case when "." is a valid and correct source of my mapping. It is officially supported mapping source, so why the plugin reports it as "should not be used"? Is there any particular reason or maybe it is just a historical burden from the times when MapStruct actually didn't support "." as a source?
Example:
record Failure(String code, String detail) {}
class Foo {
Failure failure;
}
class FooDto {
String failureCode;
String failureDetail;
}
public abstract class FooMapper {
@Mapping(target = "failure", source = ".")
public abstract Foo fromDto(FooDto fooDto);
protected Failure mapFailure(FooDto fooDto) {
return new Failure(fooDto.getFailureCode(), fooDto.getFailureDetail());
}
}
Of course, in this particular case we can just use:
@Mapping(target = "failure.code", source = "failureCode")
@Mapping(target = "failure.detail", source = "failureDetail")
But there are more complex cases when the target object should be created manually, by a custom code, and the only possible source is the whole source object.
- Lingua principale
- Java
- Stelle
- 168
- Fork
- 41
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di mapstruct/mapstruct-idea
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
mapstruct/mapstruct-idea#274 · 2 commenti ·
-
feature hack.commit.push
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
mapstruct/mapstruct-idea#267 ·
-
feature hack.commit.push
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
mapstruct/mapstruct-idea#266 ·
-
feature hack.commit.push
Difficoltà 3/5 1-2 giorni Idoneità per principianti 75/100
mapstruct/mapstruct-idea#265 ·
-
hack.commit.push
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
mapstruct/mapstruct-idea#256 ·
Tutte le issue di mapstruct/mapstruct-idea
Issue simili
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/flink-agents#1152 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
objectionary/eo-graphs#75 ·