diff --git a/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java b/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java index e78be940..ad1f05eb 100644 --- a/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java +++ b/src/main/java/org/mapstruct/intellij/util/MapstructUtil.java @@ -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() ); } @@ -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. *

diff --git a/testData/mapping/dto/CarDto.java b/testData/mapping/dto/CarDto.java index d31feee4..45ac5447 100644 --- a/testData/mapping/dto/CarDto.java +++ b/testData/mapping/dto/CarDto.java @@ -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; } diff --git a/testData/mapping/dto/FluentCarDto.java b/testData/mapping/dto/FluentCarDto.java index 7b50b86e..c16cb02a 100644 --- a/testData/mapping/dto/FluentCarDto.java +++ b/testData/mapping/dto/FluentCarDto.java @@ -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; }