Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/main/java/org/mapstruct/intellij/util/MapstructUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public static boolean isFluentSetter(@NotNull PsiMethod method, PsiType psiType)
return !psiType.getCanonicalText().startsWith( "java.lang" ) &&
method.getReturnType() != null &&
!isAdderWithUpperCase4thCharacter( method ) &&
!isRemoverWithUpperCase7thCharacter( method ) &&
isAssignableFromReturnTypeOrSuperTypes( psiType, method.getReturnType() );
}

Expand Down Expand Up @@ -239,6 +240,13 @@ private static boolean isAdderWithUpperCase4thCharacter(@NotNull PsiMethod metho
Character.isUpperCase( methodName.charAt( 3 ) );
}

private static boolean isRemoverWithUpperCase7thCharacter(@NotNull PsiMethod method) {
String methodName = method.getName();
return methodName.startsWith( "remove" ) &&
methodName.length() > 6 &&
Character.isUpperCase( methodName.charAt( 6 ) );
}

/**
* Checks if the {@code method} is a possible builder creation method.
* <p>
Expand Down
6 changes: 6 additions & 0 deletions testData/mapping/dto/CarDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ public void addPassenger(PersonDto passenger) {
this.passengers.add( passenger );
}

public void removePassenger(PersonDTO passenger) {
if ( this.passengers != null ) {
this.passengers.remove( passenger );
}
}

public Long getPrice() {
return price;
}
Expand Down
7 changes: 7 additions & 0 deletions testData/mapping/dto/FluentCarDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public FluentCarDto addPassenger(PersonDto passenger) {
return this;
}

public FluentCarDto removePassenger(PersonDto passenger) {
if ( this.passengers != null ) {
this.passengers.remove( passenger );
}
return this;
}

public Long getPrice() {
return price;
}
Expand Down