From 754f39e6ef03ce3e511a86c59dd465f99e79bca7 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 17 Oct 2022 23:38:39 -0700 Subject: [PATCH] Polish --- .../PropertyDescriptorResolver.java | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java index c5389993a7..bbde41cdd7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/PropertyDescriptorResolver.java @@ -24,7 +24,6 @@ import java.util.stream.Stream; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.ExecutableElement; -import javax.lang.model.element.NestingKind; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import javax.lang.model.type.TypeMirror; @@ -143,16 +142,13 @@ class PropertyDescriptorResolver { private final TypeElement type; - private final boolean constructorBoundType; - private final List constructors; private final List boundConstructors; - ConfigurationPropertiesTypeElement(TypeElement type, boolean constructorBoundType, - List constructors, List boundConstructors) { + ConfigurationPropertiesTypeElement(TypeElement type, List constructors, + List boundConstructors) { this.type = type; - this.constructorBoundType = constructorBoundType; this.constructors = constructors; this.boundConstructors = boundConstructors; } @@ -162,11 +158,11 @@ class PropertyDescriptorResolver { } boolean isConstructorBindingEnabled() { - return this.constructorBoundType || !this.boundConstructors.isEmpty(); + return !this.boundConstructors.isEmpty(); } ExecutableElement getBindConstructor() { - if (this.constructorBoundType && this.boundConstructors.isEmpty()) { + if (this.boundConstructors.isEmpty()) { return findBoundConstructor(); } if (this.boundConstructors.size() == 1) { @@ -189,10 +185,9 @@ class PropertyDescriptorResolver { } static ConfigurationPropertiesTypeElement of(TypeElement type, MetadataGenerationEnvironment env) { - boolean constructorBoundType = isConstructorBoundType(type, env); List constructors = ElementFilter.constructorsIn(type.getEnclosedElements()); List boundConstructors = getBoundConstructors(env, constructors); - return new ConfigurationPropertiesTypeElement(type, constructorBoundType, constructors, boundConstructors); + return new ConfigurationPropertiesTypeElement(type, constructors, boundConstructors); } private static List getBoundConstructors(MetadataGenerationEnvironment env, @@ -213,13 +208,6 @@ class PropertyDescriptorResolver { return null; } - private static boolean isConstructorBoundType(TypeElement type, MetadataGenerationEnvironment env) { - if (type.getNestingKind() == NestingKind.MEMBER) { - return isConstructorBoundType((TypeElement) type.getEnclosingElement(), env); - } - return false; - } - } }