From 39f21660463e4408885e7fd38ebdfae1f0d31c75 Mon Sep 17 00:00:00 2001 From: Andreas Gudian Date: Sun, 3 Nov 2013 13:36:53 +0100 Subject: [PATCH] #69 Only take public getters/setters into consideration --- .../src/main/java/org/mapstruct/ap/util/Executables.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/processor/src/main/java/org/mapstruct/ap/util/Executables.java b/processor/src/main/java/org/mapstruct/ap/util/Executables.java index 97059d0ab..7da229f3c 100644 --- a/processor/src/main/java/org/mapstruct/ap/util/Executables.java +++ b/processor/src/main/java/org/mapstruct/ap/util/Executables.java @@ -24,6 +24,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Modifier; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeKind; @@ -45,7 +46,7 @@ public class Executables { } public boolean isGetterMethod(ExecutableElement method) { - return isNonBooleanGetterMethod( method ) || isBooleanGetterMethod( method ); + return isPublic( method ) && ( isNonBooleanGetterMethod( method ) || isBooleanGetterMethod( method ) ); } private boolean isNonBooleanGetterMethod(ExecutableElement method) { @@ -69,7 +70,7 @@ public class Executables { public boolean isSetterMethod(ExecutableElement method) { String name = method.getSimpleName().toString(); - if ( name.startsWith( "set" ) && name.length() > 3 && method.getParameters() + if ( isPublic( method ) && name.startsWith( "set" ) && name.length() > 3 && method.getParameters() .size() == 1 && method.getReturnType().getKind() == TypeKind.VOID ) { return true; } @@ -77,6 +78,10 @@ public class Executables { return false; } + private boolean isPublic(ExecutableElement method) { + return method.getModifiers().contains( Modifier.PUBLIC ); + } + public String getPropertyName(ExecutableElement getterOrSetterMethod) { if ( isNonBooleanGetterMethod( getterOrSetterMethod ) ) { return Introspector.decapitalize(