mapstruct / mapstruct/mapstruct-idea
Unexpected warning: ''.'' should not be used as a source
- Dominant language
- Java
- Stars
- 168
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
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:
```java
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:
```java
@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.
Contributor guide
No contributing guide indexed for this repository
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.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100