mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#69 Only take public getters/setters into consideration
This commit is contained in:
parent
4c32abbeb5
commit
39f2166046
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user