mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
More detailed check for adder in builde
This commit is contained in:
parent
adde6826a6
commit
84bf019fdf
@ -102,11 +102,24 @@ public class DefaultAccessorNamingStrategy implements AccessorNamingStrategy {
|
|||||||
protected boolean isBuilderSetter(ExecutableElement method) {
|
protected boolean isBuilderSetter(ExecutableElement method) {
|
||||||
return method.getParameters().size() == 1 &&
|
return method.getParameters().size() == 1 &&
|
||||||
!JAVA_JAVAX_PACKAGE.matcher( method.getEnclosingElement().asType().toString() ).matches() &&
|
!JAVA_JAVAX_PACKAGE.matcher( method.getEnclosingElement().asType().toString() ).matches() &&
|
||||||
!isAdderMethod( method ) &&
|
!isAdderWithUpperCase4thCharacter( method ) &&
|
||||||
//TODO The Types need to be compared with Types#isSameType(TypeMirror, TypeMirror)
|
//TODO The Types need to be compared with Types#isSameType(TypeMirror, TypeMirror)
|
||||||
method.getReturnType().toString().equals( method.getEnclosingElement().asType().toString() );
|
method.getReturnType().toString().equals( method.getEnclosingElement().asType().toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the method is an adder with an upper case 4th character. The reason for this is that methods such
|
||||||
|
* as {@code address(String address)} are considered as setter and {@code addName(String name)} too. We need to
|
||||||
|
* make sure that {@code addName} is considered as an adder and {@code address} is considered as a setter.
|
||||||
|
*
|
||||||
|
* @param method the method that needs to be checked
|
||||||
|
*
|
||||||
|
* @return {@code true} if the method is an adder with an upper case 4h character, {@code false} otherwise
|
||||||
|
*/
|
||||||
|
private boolean isAdderWithUpperCase4thCharacter(ExecutableElement method) {
|
||||||
|
return isAdderMethod( method ) && Character.isUpperCase( method.getSimpleName().toString().charAt( 3 ) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} when the {@link ExecutableElement} is an adder method. An adder method starts with 'add'.
|
* Returns {@code true} when the {@link ExecutableElement} is an adder method. An adder method starts with 'add'.
|
||||||
* The remainder of the name is supposed to reflect the <em>singular</em> property name (as opposed to plural) of
|
* The remainder of the name is supposed to reflect the <em>singular</em> property name (as opposed to plural) of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user