Support record canonical constructor in BeanUtils
See gh-33707
This commit is contained in:
committed by
Sébastien Deleuze
parent
161d3995bf
commit
514d6000d1
@@ -521,10 +521,26 @@ class BeanUtilsTests {
|
||||
assertThat(BeanUtils.isSimpleProperty(type)).as("Type [" + type.getName() + "] should not be a simple property").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveRecordConstructor() throws NoSuchMethodException {
|
||||
assertThat(BeanUtils.getResolvableConstructor(RecordWithMultiplePublicConstructors.class))
|
||||
.isEqualTo(getRecordWithMultipleVariationsConstructor());
|
||||
}
|
||||
|
||||
private void assertSignatureEquals(Method desiredMethod, String signature) {
|
||||
assertThat(BeanUtils.resolveSignature(signature, MethodSignatureBean.class)).isEqualTo(desiredMethod);
|
||||
}
|
||||
|
||||
public record RecordWithMultiplePublicConstructors(String value, String name) {
|
||||
public RecordWithMultiplePublicConstructors(String value) {
|
||||
this(value, "default value");
|
||||
}
|
||||
}
|
||||
|
||||
private Constructor<RecordWithMultiplePublicConstructors> getRecordWithMultipleVariationsConstructor() throws NoSuchMethodException {
|
||||
return RecordWithMultiplePublicConstructors.class.getConstructor(String.class, String.class);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class NumberHolder {
|
||||
|
||||
Reference in New Issue
Block a user