mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-19 22:09:01 +00:00
Merge branch '3.4.x' into 3.5.x
Closes gh-46663
This commit is contained in:
+6
-9
@@ -85,12 +85,13 @@ class PropertyDescriptorResolver {
|
||||
|
||||
private PropertyDescriptor extracted(TypeElement declaringElement, TypeElementMembers members,
|
||||
VariableElement parameter) {
|
||||
String name = getPropertyName(parameter);
|
||||
String parameterName = parameter.getSimpleName().toString();
|
||||
String name = getPropertyName(parameter, parameterName);
|
||||
TypeMirror type = parameter.asType();
|
||||
ExecutableElement getter = members.getPublicGetter(name, type);
|
||||
ExecutableElement setter = members.getPublicSetter(name, type);
|
||||
VariableElement field = members.getFields().get(name);
|
||||
RecordComponentElement recordComponent = members.getRecordComponents().get(name);
|
||||
ExecutableElement getter = members.getPublicGetter(parameterName, type);
|
||||
ExecutableElement setter = members.getPublicSetter(parameterName, type);
|
||||
VariableElement field = members.getFields().get(parameterName);
|
||||
RecordComponentElement recordComponent = members.getRecordComponents().get(parameterName);
|
||||
return (recordComponent != null)
|
||||
? new RecordParameterPropertyDescriptor(name, type, parameter, declaringElement, getter,
|
||||
recordComponent)
|
||||
@@ -98,10 +99,6 @@ class PropertyDescriptorResolver {
|
||||
field);
|
||||
}
|
||||
|
||||
private String getPropertyName(VariableElement parameter) {
|
||||
return getPropertyName(parameter, parameter.getSimpleName().toString());
|
||||
}
|
||||
|
||||
private String getPropertyName(VariableElement parameter, String fallback) {
|
||||
AnnotationMirror nameAnnotation = this.environment.getNameAnnotation(parameter);
|
||||
if (nameAnnotation != null) {
|
||||
|
||||
+5
@@ -266,6 +266,9 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene
|
||||
.fromSource(type)
|
||||
.withDeprecation("some-reason", null, null));
|
||||
assertThat(metadata).has(Metadata.withProperty("deprecated-record.bravo", String.class).fromSource(type));
|
||||
assertThat(metadata).has(Metadata.withProperty("deprecated-record.named.charlie", String.class)
|
||||
.fromSource(type)
|
||||
.withDeprecation("another-reason", null, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -570,6 +573,8 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene
|
||||
.withDescription("description without space after asterisk"));
|
||||
assertThat(metadata).has(Metadata.withProperty("record.descriptions.some-byte", Byte.class)
|
||||
.withDescription("last description in Javadoc"));
|
||||
assertThat(metadata).has(Metadata.withProperty("record.descriptions.named.record.component", String.class)
|
||||
.withDescription("description of a named component"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+5
-6
@@ -16,22 +16,21 @@
|
||||
|
||||
package org.springframework.boot.configurationsample.record;
|
||||
|
||||
// @formatter:off
|
||||
import org.springframework.boot.configurationsample.Name;
|
||||
|
||||
/**
|
||||
* Example Record Javadoc sample
|
||||
*
|
||||
* @param someString very long description that
|
||||
* doesn't fit single line and is indented
|
||||
* @param someString very long description that doesn't fit single line and is indented
|
||||
* @param someInteger description with @param and @ pitfalls
|
||||
* @param someBoolean description with extra spaces
|
||||
* @param someLong description without space after asterisk
|
||||
* @param namedComponent description of a named component
|
||||
* @param someByte last description in Javadoc
|
||||
* @since 1.0.0
|
||||
* @author Pavel Anisimov
|
||||
*/
|
||||
@org.springframework.boot.configurationsample.ConfigurationProperties("record.descriptions")
|
||||
public record ExampleRecord(String someString, Integer someInteger, Boolean someBoolean, Long someLong, Byte someByte) {
|
||||
public record ExampleRecord(String someString, Integer someInteger, Boolean someBoolean, Long someLong,
|
||||
@Name("named.record.component") String namedComponent, Byte someByte) {
|
||||
}
|
||||
|
||||
//@formatter:on
|
||||
|
||||
+8
-1
@@ -18,16 +18,18 @@ package org.springframework.boot.configurationsample.simple;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.boot.configurationsample.DeprecatedConfigurationProperty;
|
||||
import org.springframework.boot.configurationsample.Name;
|
||||
|
||||
/**
|
||||
* Configuration properties as record with deprecated property.
|
||||
*
|
||||
* @param alpha alpha property, deprecated
|
||||
* @param bravo bravo property
|
||||
* @param charlie charlie property, named, deprecated
|
||||
* @author Moritz Halbritter
|
||||
*/
|
||||
@ConfigurationProperties("deprecated-record")
|
||||
public record DeprecatedRecord(String alpha, String bravo) {
|
||||
public record DeprecatedRecord(String alpha, String bravo, @Name("named.charlie") String charlie) {
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(reason = "some-reason")
|
||||
@@ -35,4 +37,9 @@ public record DeprecatedRecord(String alpha, String bravo) {
|
||||
return this.alpha;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(reason = "another-reason")
|
||||
public String charlie() {
|
||||
return this.charlie;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user