Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private static void handleMappingAnnotation(PsiAnnotation psiAnnotation,
PsiAnnotationMemberValue value = psiAnnotation.findDeclaredAttributeValue( "target" );
if (value != null) {
String target = getStringAttributeValue( value );
if (target != null) {
if (target != null && !target.equals( "." )) {
problemMap.computeIfAbsent( target, k -> new ArrayList<>() ).add( value );
}
}
Expand Down
59 changes: 59 additions & 0 deletions testData/inspection/TargetPropertyMappedMoreThanOnce.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,57 @@ public void setLastName(String lastName) {
}
}

class ComplexSource {
private Source source;
private Target target;

public Source getSource() {
return source;
}

public void setSource(Source source) {
this.source = source;
}

public Target getTarget() {
return target;
}

public void setTarget(Target target) {
this.target = target;
}
}

class ComplexTarget {
private String testName;
private String name;
private String lastName;

public String getTestName() {
return testName;
}

public void setTestName(String testName) {
this.testName = testName;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}
}

@Retention(RetentionPolicy.CLASS)
@Mapping(target = "testName", source = "name")
@interface MyMappingAnnotation {
Expand Down Expand Up @@ -94,4 +145,12 @@ interface TargetMappedMoreThanOnceByMyMappingAnnotationAndMappingsAnnotationMapp
})
<error descr="Target property 'testName' must not be mapped more than once.">@MyMappingAnnotation</error>
Target map(Source source);
}

@Mapper
interface MultipleTargetDotMapper {

@Mapping(target = ".", source = "source")
@Mapping(target = ".", source = "target")
ComplexTarget map(ComplexSource source);
}
59 changes: 59 additions & 0 deletions testData/inspection/TargetPropertyMappedMoreThanOnce_after.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,57 @@ public void setLastName(String lastName) {
}
}

class ComplexSource {
private Source source;
private Target target;

public Source getSource() {
return source;
}

public void setSource(Source source) {
this.source = source;
}

public Target getTarget() {
return target;
}

public void setTarget(Target target) {
this.target = target;
}
}

class ComplexTarget {
private String testName;
private String name;
private String lastName;

public String getTestName() {
return testName;
}

public void setTestName(String testName) {
this.testName = testName;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}
}

@Retention(RetentionPolicy.CLASS)
@Mapping(target = "testName", source = "name")
@interface MyMappingAnnotation {
Expand Down Expand Up @@ -90,4 +141,12 @@ interface TargetMappedMoreThanOnceByMyMappingAnnotationAndMappingsAnnotationMapp
})
@MyMappingAnnotation
Target map(Source source);
}

@Mapper
interface MultipleTargetDotMapper {

@Mapping(target = ".", source = "source")
@Mapping(target = ".", source = "target")
ComplexTarget map(ComplexSource source);
}