Ignore 'value' attribute in AnnotationTypeMapping
Update `addConventionAnnotationValues` so that `value` attributes do not override existing annotation values. The aligns the new `MergedAnnotations` API with the previous `AnnotatedElementUtils` logic. Closes gh-22703
This commit is contained in:
@@ -822,6 +822,14 @@ public class AnnotatedElementUtilsTests {
|
||||
assertThat(element.getDeclaredAnnotations()).isNotSameAs(element.getDeclaredAnnotations());
|
||||
}
|
||||
|
||||
@Test // gh-22703
|
||||
public void getMergedAnnotationOnThreeDeepMetaWithValue() {
|
||||
ValueAttribute annotation = AnnotatedElementUtils.getMergedAnnotation(
|
||||
ValueAttributeMetaMetaClass.class, ValueAttribute.class);
|
||||
assertThat(annotation.value()).containsExactly("FromValueAttributeMeta");
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@MetaCycle3
|
||||
@@ -1394,4 +1402,32 @@ public class AnnotatedElementUtilsTests {
|
||||
class ForAnnotationsClass {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
static @interface ValueAttribute {
|
||||
|
||||
String[] value();
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValueAttribute("FromValueAttributeMeta")
|
||||
static @interface ValueAttributeMeta {
|
||||
|
||||
@AliasFor("alias")
|
||||
String[] value() default {};
|
||||
|
||||
@AliasFor("value")
|
||||
String[] alias() default {};
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValueAttributeMeta("FromValueAttributeMetaMeta")
|
||||
static @interface ValueAttributeMetaMeta {
|
||||
}
|
||||
|
||||
@ValueAttributeMetaMeta
|
||||
static class ValueAttributeMetaMetaClass {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2045,6 +2045,14 @@ public class MergedAnnotationsTests {
|
||||
assertThat(annotation.getString("value")).isEqualTo("meta");
|
||||
}
|
||||
|
||||
@Test // gh-22703
|
||||
public void getValueWhenThreeDeepMetaWithValue() {
|
||||
MergedAnnotation<?> annotation = MergedAnnotations.from(
|
||||
ValueAttributeMetaMetaClass.class).get(ValueAttribute.class);
|
||||
assertThat(annotation.getStringArray(MergedAnnotation.VALUE)).containsExactly(
|
||||
"FromValueAttributeMeta");
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@@ -3430,6 +3438,31 @@ public class MergedAnnotationsTests {
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
static @interface ValueAttribute {
|
||||
|
||||
String[] value();
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValueAttribute("FromValueAttributeMeta")
|
||||
static @interface ValueAttributeMeta {
|
||||
|
||||
String[] value() default {};
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ValueAttributeMeta("FromValueAttributeMetaMeta")
|
||||
static @interface ValueAttributeMetaMeta {
|
||||
|
||||
}
|
||||
|
||||
@ValueAttributeMetaMeta
|
||||
static class ValueAttributeMetaMetaClass {
|
||||
|
||||
}
|
||||
// @formatter:on
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user