Detect builder-style setter
Previously, a setter method that was returning the current instance was not identified as a "setter" by the configuration processor. As a result, builder-style APIs were not covered by the configuration metadata. If a setter returns either void or the current class, it is now recognized as a valid setter. Fixes gh-1854
This commit is contained in:
@@ -91,7 +91,12 @@ class TypeElementMembers {
|
||||
private boolean isSetter(ExecutableElement method) {
|
||||
final String name = method.getSimpleName().toString();
|
||||
return name.startsWith("set") && method.getParameters().size() == 1
|
||||
&& (TypeKind.VOID == method.getReturnType().getKind());
|
||||
&& (isSetterReturnType(method));
|
||||
}
|
||||
|
||||
private boolean isSetterReturnType(ExecutableElement method) {
|
||||
return (TypeKind.VOID == method.getReturnType().getKind()
|
||||
|| method.getEnclosingElement().asType().equals(method.getReturnType()));
|
||||
}
|
||||
|
||||
private String getAccessorName(String methodName) {
|
||||
|
||||
Reference in New Issue
Block a user