mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
See gh-8762
This commit is contained in:
parent
5781f4fef0
commit
adaa49c0df
@ -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<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,
|
||||
|
@ -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
|
@ -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;
|
||||
}
|
||||
|
@ -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<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…
Reference in New Issue
Block a user