Unexpected warning: ''.'' should not be used as a source
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by reproducing the warning with the FooMapper example and inspect how the MapStruct IntelliJ plugin handles @Mapping values whose source is ".". Compare that behavior with MapStruct's documented support for the source form; done means the valid mapping is no longer incorrectly warned about, or the reason for the warning is clearly established.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 168
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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.
More from mapstruct/mapstruct-idea
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
mapstruct/mapstruct-idea#274 · 2 comments ·
-
feature hack.commit.push
Difficulty 3/5 1-2 days Newbie friendliness 68/100
mapstruct/mapstruct-idea#267 ·
-
feature hack.commit.push
Difficulty 3/5 1-2 days Newbie friendliness 55/100
mapstruct/mapstruct-idea#266 ·
-
feature hack.commit.push
Difficulty 3/5 1-2 days Newbie friendliness 75/100
mapstruct/mapstruct-idea#265 ·
-
hack.commit.push
Difficulty 5/5 Over a week Newbie friendliness 20/100
mapstruct/mapstruct-idea#256 ·
All issues in mapstruct/mapstruct-idea
Similar issues
-
bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
opensearch-project/ml-commons#5094 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
emitter:client:csharp feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
affects/8.10 affects/8.9 component/clients kind/bug likelihood/mid severity/mid
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Two open-case totals on one screen: the Programs tile says 15,858 and the nav badge says 15,868 Openbug frontend maui-pilot
Difficulty 2/5 1-3 hours Newbie friendliness 72/100