Remove null check before instanceof

Closes gh-10033
This commit is contained in:
Johnny Lim 2017-08-18 01:31:14 +09:00 committed by Stephane Nicoll
parent 74c5e48715
commit 9439467664
1 changed files with 4 additions and 7 deletions

View File

@ -338,8 +338,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
boolean isNested = isNested(returnElement, field, element); boolean isNested = isNested(returnElement, field, element);
AnnotationMirror annotation = getAnnotation(getter, AnnotationMirror annotation = getAnnotation(getter,
configurationPropertiesAnnotation()); configurationPropertiesAnnotation());
if (returnElement != null && returnElement instanceof TypeElement if (returnElement instanceof TypeElement && annotation == null && isNested) {
&& annotation == null && isNested) {
String nestedPrefix = ConfigurationMetadata.nestedPrefix(prefix, name); String nestedPrefix = ConfigurationMetadata.nestedPrefix(prefix, name);
this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix, this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix,
this.typeUtils.getQualifiedName(returnElement), this.typeUtils.getQualifiedName(returnElement),
@ -419,8 +418,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
} }
private Element getTopLevelType(Element element) { private Element getTopLevelType(Element element) {
if ((element.getEnclosingElement() == null) if (!(element.getEnclosingElement() instanceof TypeElement)) {
|| !(element.getEnclosingElement() instanceof TypeElement)) {
return element; return element;
} }
return getTopLevelType(element.getEnclosingElement()); return getTopLevelType(element.getEnclosingElement());
@ -430,8 +428,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
if (isElementDeprecated(element)) { if (isElementDeprecated(element)) {
return true; return true;
} }
if (element != null && (element instanceof VariableElement if (element instanceof VariableElement || element instanceof ExecutableElement) {
|| element instanceof ExecutableElement)) {
return isElementDeprecated(element.getEnclosingElement()); return isElementDeprecated(element.getEnclosingElement());
} }
return false; return false;
@ -535,7 +532,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
} }
static EndpointTypes parse(Object typesAttribute) { static EndpointTypes parse(Object typesAttribute) {
if (typesAttribute == null || !(typesAttribute instanceof List)) { if (!(typesAttribute instanceof List)) {
return new EndpointTypes(ALL_TYPES); return new EndpointTypes(ALL_TYPES);
} }
List<AnnotationValue> values = (List<AnnotationValue>) typesAttribute; List<AnnotationValue> values = (List<AnnotationValue>) typesAttribute;