Browse Source

Polish

See gh-8762
pull/16242/head
Stephane Nicoll 7 years ago
parent
commit
adaa49c0df
  1. 5
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinder.java
  2. 4
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java
  3. 4
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java
  4. 9
      spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinderTests.java

5
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinder.java

@ -30,7 +30,6 @@ import kotlin.reflect.KParameter; @@ -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 { @@ -153,8 +152,8 @@ class ConstructorParametersBinder implements BeanBinder {
Map<String, ConstructorParameter> 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,

4
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertyDefaultValue.java → spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/DefaultValue.java

@ -13,7 +13,7 @@ @@ -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; @@ -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

4
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; @@ -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 { @@ -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;
}

9
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/ConstructorParametersBinderTests.java

@ -21,7 +21,6 @@ import java.util.List; @@ -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 { @@ -259,11 +258,9 @@ public class ConstructorParametersBinderTests {
private final List<String> customList;
public ExampleDefaultValueBean(
@ConfigurationPropertyDefaultValue("5") int intValue,
@ConfigurationPropertyDefaultValue({ "a", "b",
"c" }) List<String> stringsList,
@ConfigurationPropertyDefaultValue("x,y,z") List<String> customList) {
public ExampleDefaultValueBean(@DefaultValue("5") int intValue,
@DefaultValue({ "a", "b", "c" }) List<String> stringsList,
@DefaultValue("x,y,z") List<String> customList) {
this.intValue = intValue;
this.stringsList = stringsList;
this.customList = customList;

Loading…
Cancel
Save