From adaa49c0df86cd24b878470c7e1a499b697adf61 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Fri, 15 Mar 2019 12:16:05 +0100 Subject: [PATCH] Polish See gh-8762 --- .../properties/bind/ConstructorParametersBinder.java | 5 ++--- .../DefaultValue.java} | 4 ++-- .../context/properties/ConfigurationPropertiesTests.java | 4 ++-- .../bind/ConstructorParametersBinderTests.java | 9 +++------ 4 files changed, 9 insertions(+), 13 deletions(-) rename spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/{ConfigurationPropertyDefaultValue.java => bind/DefaultValue.java} (92%) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinder.java index 3d73803df4f..b5c98d0a755 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinder.java @@ -30,7 +30,6 @@ import kotlin.reflect.KParameter; import kotlin.reflect.jvm.ReflectJvmMapping; import org.springframework.beans.BeanUtils; -import org.springframework.boot.context.properties.ConfigurationPropertyDefaultValue; import org.springframework.boot.context.properties.source.ConfigurationPropertyName; import org.springframework.core.KotlinDetector; import org.springframework.core.ResolvableType; @@ -153,8 +152,8 @@ class ConstructorParametersBinder implements BeanBinder { Map parameters = new LinkedHashMap<>(); for (Parameter parameter : constructor.getParameters()) { String name = parameter.getName(); - ConfigurationPropertyDefaultValue[] annotationsByType = parameter - .getAnnotationsByType(ConfigurationPropertyDefaultValue.class); + DefaultValue[] annotationsByType = parameter + .getAnnotationsByType(DefaultValue.class); String[] defaultValue = (annotationsByType.length > 0) ? annotationsByType[0].value() : null; parameters.computeIfAbsent(name, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertyDefaultValue.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java similarity index 92% rename from spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertyDefaultValue.java rename to spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java index c55d3e4e204..5b5b3f9a4d5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertyDefaultValue.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.boot.context.properties; +package org.springframework.boot.context.properties.bind; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.PARAMETER }) @Documented -public @interface ConfigurationPropertyDefaultValue { +public @interface DefaultValue { /** * The default value of the property. Can be an array of values for collection or diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index 2374e493ee6..38f51160b00 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -47,6 +47,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.boot.context.properties.bind.BindException; +import org.springframework.boot.context.properties.bind.DefaultValue; import org.springframework.boot.context.properties.bind.validation.BindValidationException; import org.springframework.boot.convert.DataSizeUnit; import org.springframework.boot.testsupport.rule.OutputCapture; @@ -1849,8 +1850,7 @@ public class ConfigurationPropertiesTests { private final int bar; - ConstructorParameterProperties( - @ConfigurationPropertyDefaultValue("hello") String foo, int bar) { + ConstructorParameterProperties(@DefaultValue("hello") String foo, int bar) { this.foo = foo; this.bar = bar; } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinderTests.java index c9feb993dd6..35ebec520cf 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinderTests.java @@ -21,7 +21,6 @@ import java.util.List; import org.junit.Before; import org.junit.Test; -import org.springframework.boot.context.properties.ConfigurationPropertyDefaultValue; import org.springframework.boot.context.properties.source.ConfigurationPropertyName; import org.springframework.boot.context.properties.source.ConfigurationPropertySource; import org.springframework.boot.context.properties.source.MockConfigurationPropertySource; @@ -259,11 +258,9 @@ public class ConstructorParametersBinderTests { private final List customList; - public ExampleDefaultValueBean( - @ConfigurationPropertyDefaultValue("5") int intValue, - @ConfigurationPropertyDefaultValue({ "a", "b", - "c" }) List stringsList, - @ConfigurationPropertyDefaultValue("x,y,z") List customList) { + public ExampleDefaultValueBean(@DefaultValue("5") int intValue, + @DefaultValue({ "a", "b", "c" }) List stringsList, + @DefaultValue("x,y,z") List customList) { this.intValue = intValue; this.stringsList = stringsList; this.customList = customList;