Ignore static and abstract accessors
This commit updates the annotation processor and the binder to ignore any static or abstract method that has the characteristics of a JavaBean accessor. As a result, no property is generated for those (invalid) accessor and no binding occurs on them either. Closes gh-12390
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.lang.model.element.Element;
|
||||
@@ -97,7 +98,7 @@ class TypeElementMembers {
|
||||
}
|
||||
|
||||
private void processMethod(ExecutableElement method) {
|
||||
if (method.getModifiers().contains(Modifier.PUBLIC)) {
|
||||
if (isPublic(method)) {
|
||||
String name = method.getSimpleName().toString();
|
||||
if (isGetter(method) && !this.publicGetters.containsKey(name)) {
|
||||
this.publicGetters.put(getAccessorName(name), method);
|
||||
@@ -118,6 +119,13 @@ class TypeElementMembers {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPublic(ExecutableElement method) {
|
||||
Set<Modifier> modifiers = method.getModifiers();
|
||||
return modifiers.contains(Modifier.PUBLIC)
|
||||
&& !modifiers.contains(Modifier.ABSTRACT)
|
||||
&& !modifiers.contains(Modifier.STATIC);
|
||||
}
|
||||
|
||||
private ExecutableElement getMatchingSetter(List<ExecutableElement> candidates,
|
||||
TypeMirror type) {
|
||||
for (ExecutableElement candidate : candidates) {
|
||||
|
||||
Reference in New Issue
Block a user