Browse Source

Short circuit if-conditions in AttributeMethods

pull/28119/head
Sam Brannen 3 years ago
parent
commit
4eaee1e738
  1. 7
      spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java

7
spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,6 +32,7 @@ import org.springframework.util.ReflectionUtils;
* with consistent ordering as well as a few useful utility methods. * with consistent ordering as well as a few useful utility methods.
* *
* @author Phillip Webb * @author Phillip Webb
* @author Sam Brannen
* @since 5.2 * @since 5.2
*/ */
final class AttributeMethods { final class AttributeMethods {
@ -71,10 +72,10 @@ final class AttributeMethods {
for (int i = 0; i < attributeMethods.length; i++) { for (int i = 0; i < attributeMethods.length; i++) {
Method method = this.attributeMethods[i]; Method method = this.attributeMethods[i];
Class<?> type = method.getReturnType(); Class<?> type = method.getReturnType();
if (method.getDefaultValue() != null) { if (!foundDefaultValueMethod && (method.getDefaultValue() != null)) {
foundDefaultValueMethod = true; foundDefaultValueMethod = true;
} }
if (type.isAnnotation() || (type.isArray() && type.getComponentType().isAnnotation())) { if (!foundNestedAnnotation && (type.isAnnotation() || (type.isArray() && type.getComponentType().isAnnotation()))) {
foundNestedAnnotation = true; foundNestedAnnotation = true;
} }
ReflectionUtils.makeAccessible(method); ReflectionUtils.makeAccessible(method);

Loading…
Cancel
Save