This commit is contained in:
Andy Wilkinson 2024-05-02 08:40:56 +01:00
parent 16291b0fcf
commit 94c9a5c686
2 changed files with 3 additions and 73 deletions

View File

@ -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++) {

View File

@ -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) {
}
}