mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Polish
This commit is contained in:
parent
16291b0fcf
commit
94c9a5c686
|
@ -181,7 +181,7 @@ class TypeUtils {
|
|||
return getJavaDoc((RecordComponentElement) element);
|
||||
}
|
||||
String javadoc = (element != null) ? this.env.getElementUtils().getDocComment(element) : null;
|
||||
javadoc = (javadoc != null) ? cleanupJavaDoc(javadoc) : null;
|
||||
javadoc = (javadoc != null) ? cleanUpJavaDoc(javadoc) : null;
|
||||
return (javadoc == null || javadoc.isEmpty()) ? null : javadoc;
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ class TypeUtils {
|
|||
Pattern paramJavadocPattern = paramJavadocPattern(recordComponent.getSimpleName().toString());
|
||||
Matcher paramJavadocMatcher = paramJavadocPattern.matcher(recordJavadoc);
|
||||
if (paramJavadocMatcher.find()) {
|
||||
String paramJavadoc = cleanupJavaDoc(paramJavadocMatcher.group());
|
||||
String paramJavadoc = cleanUpJavaDoc(paramJavadocMatcher.group());
|
||||
return paramJavadoc.isEmpty() ? null : paramJavadoc;
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class TypeUtils {
|
|||
return Pattern.compile(pattern, Pattern.DOTALL);
|
||||
}
|
||||
|
||||
private String cleanupJavaDoc(String javadoc) {
|
||||
private String cleanUpJavaDoc(String javadoc) {
|
||||
StringBuilder result = new StringBuilder(javadoc.length());
|
||||
char lastChar = '.';
|
||||
for (int i = 0; i < javadoc.length(); i++) {
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.context.properties;
|
||||
|
||||
/**
|
||||
* @author pwebb
|
||||
*/
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.support.TestPropertySourceUtils;
|
||||
|
||||
public class TempTests {
|
||||
|
||||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@Test
|
||||
void testName() {
|
||||
load(MyConfig.class, "foo.bar.baz=hello");
|
||||
System.out.println(this.context.getBean(Foo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testName2() {
|
||||
load(MyConfig.class);
|
||||
System.out.println(this.context.getBean(Foo.class));
|
||||
}
|
||||
|
||||
private AnnotationConfigApplicationContext load(Class<?> configuration, String... inlinedProperties) {
|
||||
return load(new Class<?>[] { configuration }, inlinedProperties);
|
||||
}
|
||||
|
||||
private AnnotationConfigApplicationContext load(Class<?>[] configuration, String... inlinedProperties) {
|
||||
this.context.register(configuration);
|
||||
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, inlinedProperties);
|
||||
this.context.refresh();
|
||||
return this.context;
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(Foo.class)
|
||||
static class MyConfig {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties("foo")
|
||||
record Foo(@DefaultValue Bar bar) {
|
||||
}
|
||||
|
||||
record Bar(@DefaultValue("hello") String baz) {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user