Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Mar 15, 2019
1 parent 5781f4f commit adaa49c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
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;
Expand Down Expand Up @@ -153,8 +152,8 @@ private static Map<String, ConstructorParameter> parseParameters(
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +31,7 @@
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
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;
Expand Down Expand Up @@ -1849,8 +1850,7 @@ static class ConstructorParameterProperties {

private final int bar;

ConstructorParameterProperties(
@ConfigurationPropertyDefaultValue("hello") String foo, int bar) {
ConstructorParameterProperties(@DefaultValue("hello") String foo, int bar) {
this.foo = foo;
this.bar = bar;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;
Expand Down Expand Up @@ -259,11 +258,9 @@ public static class ExampleDefaultValueBean {

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;
Expand Down

0 comments on commit adaa49c

Please sign in to comment.