Polishing

This commit is contained in:
Sam Brannen
2019-12-10 13:14:11 +01:00
parent 8d846500ef
commit 4466114cfa

View File

@@ -213,49 +213,40 @@ class AnnotationTypeMappingsTests {
@Test
void getDistanceReturnsDistance() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class);
assertThat(mappings.get(0).getDistance()).isEqualTo(0);
assertThat(mappings.get(1).getDistance()).isEqualTo(1);
}
@Test
void getAnnotationTypeReturnsAnnotationType() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class);
assertThat(mappings.get(0).getAnnotationType()).isEqualTo(Mapped.class);
assertThat(mappings.get(1).getAnnotationType()).isEqualTo(MappedTarget.class);
}
@Test
void getMetaTypeReturnsTypes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ThreeDeepA.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ThreeDeepA.class);
AnnotationTypeMapping mappingC = mappings.get(2);
assertThat(mappingC.getMetaTypes()).containsExactly(
ThreeDeepA.class, ThreeDeepB.class, ThreeDeepC.class);
assertThat(mappingC.getMetaTypes()).containsExactly(ThreeDeepA.class, ThreeDeepB.class, ThreeDeepC.class);
}
@Test
void getAnnotationWhenRootReturnsNull() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class);
assertThat(mappings.get(0).getAnnotation()).isNull();
}
@Test
void getAnnotationWhenMetaAnnotationReturnsAnnotation() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
assertThat(mappings.get(1).getAnnotation()).isEqualTo(
Mapped.class.getAnnotation(MappedTarget.class));
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(Mapped.class);
assertThat(mappings.get(1).getAnnotation()).isEqualTo(Mapped.class.getAnnotation(MappedTarget.class));
}
@Test
void getAttributesReturnsAttributes() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
Mapped.class).get(0);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(Mapped.class).get(0);
AttributeMethods attributes = mapping.getAttributes();
assertThat(attributes.size()).isEqualTo(2);
assertThat(attributes.get(0).getName()).isEqualTo("alias");
@@ -264,24 +255,19 @@ class AnnotationTypeMappingsTests {
@Test
void getAliasMappingReturnsAttributes() throws Exception {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
Mapped.class).get(1);
assertThat(getAliasMapping(mapping, 0)).isEqualTo(
Mapped.class.getDeclaredMethod("alias"));
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(Mapped.class).get(1);
assertThat(getAliasMapping(mapping, 0)).isEqualTo(Mapped.class.getDeclaredMethod("alias"));
}
@Test
void getConventionMappingReturnsAttributes() throws Exception {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
Mapped.class).get(1);
assertThat(getConventionMapping(mapping, 1)).isEqualTo(
Mapped.class.getDeclaredMethod("convention"));
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(Mapped.class).get(1);
assertThat(getConventionMapping(mapping, 1)).isEqualTo(Mapped.class.getDeclaredMethod("convention"));
}
@Test
void getMirrorSetWhenAliasPairReturnsMirrors() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
MirrorSets mirrorSets = mapping.getMirrorSets();
assertThat(mirrorSets.size()).isEqualTo(1);
assertThat(mirrorSets.get(0).size()).isEqualTo(2);
@@ -291,8 +277,7 @@ class AnnotationTypeMappingsTests {
@Test
void getMirrorSetWhenImplicitMirrorsReturnsMirrors() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ImplicitMirrors.class).get(0);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ImplicitMirrors.class).get(0);
MirrorSets mirrorSets = mapping.getMirrorSets();
assertThat(mirrorSets.size()).isEqualTo(1);
assertThat(mirrorSets.get(0).size()).isEqualTo(2);
@@ -302,8 +287,7 @@ class AnnotationTypeMappingsTests {
@Test
void getMirrorSetWhenThreeDeepReturnsMirrors() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ThreeDeepA.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ThreeDeepA.class);
AnnotationTypeMapping mappingA = mappings.get(0);
MirrorSets mirrorSetsA = mappingA.getMirrorSets();
assertThat(mirrorSetsA.size()).isEqualTo(2);
@@ -319,8 +303,7 @@ class AnnotationTypeMappingsTests {
@Test
void getAliasMappingWhenThreeDeepReturnsMappedAttributes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ThreeDeepA.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ThreeDeepA.class);
AnnotationTypeMapping mappingA = mappings.get(0);
assertThat(getAliasMapping(mappingA, 0)).isNull();
assertThat(getAliasMapping(mappingA, 1)).isNull();
@@ -337,50 +320,41 @@ class AnnotationTypeMappingsTests {
@Test
void getAliasMappingsWhenHasDefinedAttributesReturnsMappedAttributes() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
DefinedAttributes.class).get(1);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(DefinedAttributes.class).get(1);
assertThat(getAliasMapping(mapping, 0)).isNull();
assertThat(getAliasMapping(mapping, 1).getName()).isEqualTo("value");
}
@Test
void resolveMirrorsWhenAliasPairResolves() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
Method[] resolvedA = resolveMirrorSets(mapping, WithAliasPairA.class,
AliasPair.class);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
Method[] resolvedA = resolveMirrorSets(mapping, WithAliasPairA.class, AliasPair.class);
assertThat(resolvedA[0].getName()).isEqualTo("a");
assertThat(resolvedA[1].getName()).isEqualTo("a");
Method[] resolvedB = resolveMirrorSets(mapping, WithAliasPairB.class,
AliasPair.class);
Method[] resolvedB = resolveMirrorSets(mapping, WithAliasPairB.class, AliasPair.class);
assertThat(resolvedB[0].getName()).isEqualTo("b");
assertThat(resolvedB[1].getName()).isEqualTo("b");
}
@Test
void resolveMirrorsWhenHasSameValuesUsesFirst() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
Method[] resolved = resolveMirrorSets(mapping, WithSameValueAliasPair.class,
AliasPair.class);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
Method[] resolved = resolveMirrorSets(mapping, WithSameValueAliasPair.class, AliasPair.class);
assertThat(resolved[0].getName()).isEqualTo("a");
assertThat(resolved[1].getName()).isEqualTo("a");
}
@Test
void resolveMirrorsWhenOnlyHasDefaultValuesUsesFirst() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class,
AliasPair.class);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class, AliasPair.class);
assertThat(resolved[0].getName()).isEqualTo("a");
assertThat(resolved[1].getName()).isEqualTo("a");
}
@Test
void resolveMirrorsWhenHasDifferentValuesThrowsException() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
resolveMirrorSets(mapping, WithDifferentValueAliasPair.class, AliasPair.class))
.withMessage("Different @AliasFor mirror values for annotation ["
@@ -391,77 +365,58 @@ class AnnotationTypeMappingsTests {
@Test
void resolveMirrorsWhenHasWithMulipleRoutesToAliasReturnsMirrors() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
MulipleRoutesToAliasA.class);
AnnotationTypeMapping mappingsA = getMapping(mappings,
MulipleRoutesToAliasA.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MulipleRoutesToAliasA.class);
AnnotationTypeMapping mappingsA = getMapping(mappings, MulipleRoutesToAliasA.class);
assertThat(mappingsA.getMirrorSets().size()).isZero();
AnnotationTypeMapping mappingsB = getMapping(mappings,
MulipleRoutesToAliasB.class);
assertThat(getNames(mappingsB.getMirrorSets().get(0))).containsExactly("b1", "b2",
"b3");
AnnotationTypeMapping mappingsC = getMapping(mappings,
MulipleRoutesToAliasC.class);
assertThat(getNames(mappingsC.getMirrorSets().get(0))).containsExactly("c1",
"c2");
AnnotationTypeMapping mappingsB = getMapping(mappings, MulipleRoutesToAliasB.class);
assertThat(getNames(mappingsB.getMirrorSets().get(0))).containsExactly("b1", "b2", "b3");
AnnotationTypeMapping mappingsC = getMapping(mappings, MulipleRoutesToAliasC.class);
assertThat(getNames(mappingsC.getMirrorSets().get(0))).containsExactly("c1", "c2");
}
@Test
void getAliasMappingWhenHasWithMulipleRoutesToAliasReturnsMappedAttributes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
MulipleRoutesToAliasA.class);
AnnotationTypeMapping mappingsA = getMapping(mappings,
MulipleRoutesToAliasA.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MulipleRoutesToAliasA.class);
AnnotationTypeMapping mappingsA = getMapping(mappings, MulipleRoutesToAliasA.class);
assertThat(getAliasMapping(mappingsA, 0)).isNull();
AnnotationTypeMapping mappingsB = getMapping(mappings,
MulipleRoutesToAliasB.class);
AnnotationTypeMapping mappingsB = getMapping(mappings, MulipleRoutesToAliasB.class);
assertThat(getAliasMapping(mappingsB, 0).getName()).isEqualTo("a1");
assertThat(getAliasMapping(mappingsB, 1).getName()).isEqualTo("a1");
assertThat(getAliasMapping(mappingsB, 2).getName()).isEqualTo("a1");
AnnotationTypeMapping mappingsC = getMapping(mappings,
MulipleRoutesToAliasC.class);
AnnotationTypeMapping mappingsC = getMapping(mappings, MulipleRoutesToAliasC.class);
assertThat(getAliasMapping(mappingsC, 0).getName()).isEqualTo("a1");
assertThat(getAliasMapping(mappingsC, 1).getName()).isEqualTo("a1");
}
@Test
void getConventionMappingWhenConventionToExplicitAliasesReturnsMappedAttributes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ConventionToExplicitAliases.class);
AnnotationTypeMapping mapping = getMapping(mappings,
ConventionToExplicitAliasesTarget.class);
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(ConventionToExplicitAliases.class);
AnnotationTypeMapping mapping = getMapping(mappings, ConventionToExplicitAliasesTarget.class);
assertThat(mapping.getConventionMapping(0)).isEqualTo(0);
assertThat(mapping.getConventionMapping(1)).isEqualTo(0);
}
@Test
void isEquivalentToDefaultValueWhenValueAndDefaultAreNullReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValue.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, null,
ReflectionUtils::invokeMethod)).isTrue();
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValue.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, null, ReflectionUtils::invokeMethod)).isTrue();
}
@Test
void isEquivalentToDefaultValueWhenValueAndDefaultMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, InputStream.class,
ReflectionUtils::invokeMethod)).isTrue();
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, InputStream.class, ReflectionUtils::invokeMethod)).isTrue();
}
@Test
void isEquivalentToDefaultValueWhenClassAndStringNamesMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, "java.io.InputStream",
ReflectionUtils::invokeMethod)).isTrue();
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, "java.io.InputStream", ReflectionUtils::invokeMethod)).isTrue();
}
@Test
void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassArrayValueWithDefault.class).get(0);
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassArrayValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0,
new String[] { "java.io.InputStream", "java.io.OutputStream" },
ReflectionUtils::invokeMethod)).isTrue();
@@ -469,31 +424,24 @@ class AnnotationTypeMappingsTests {
@Test
void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
NestedValue.class).get(0);
Map<String, Object> value = Collections.singletonMap("value",
"java.io.InputStream");
assertThat(mapping.isEquivalentToDefaultValue(0, value,
this::extractFromMap)).isTrue();
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(NestedValue.class).get(0);
Map<String, Object> value = Collections.singletonMap("value", "java.io.InputStream");
assertThat(mapping.isEquivalentToDefaultValue(0, value, this::extractFromMap)).isTrue();
}
@Test
void isEquivalentToDefaultValueWhenNotMatchingReturnsFalse() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, OutputStream.class,
ReflectionUtils::invokeMethod)).isFalse();
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, OutputStream.class, ReflectionUtils::invokeMethod)).isFalse();
}
private Method[] resolveMirrorSets(AnnotationTypeMapping mapping, Class<?> element,
Class<? extends Annotation> annotationClass) {
Annotation annotation = element.getAnnotation(annotationClass);
int[] resolved = mapping.getMirrorSets().resolve(element.getName(), annotation,
ReflectionUtils::invokeMethod);
int[] resolved = mapping.getMirrorSets().resolve(element.getName(), annotation, ReflectionUtils::invokeMethod);
Method[] result = new Method[resolved.length];
for (int i = 0; i < resolved.length; i++) {
result[i] = resolved[i] != -1 ? mapping.getAttributes().get(resolved[i])
: null;
result[i] = resolved[i] != -1 ? mapping.getAttributes().get(resolved[i]) : null;
}
return result;
}
@@ -505,14 +453,14 @@ class AnnotationTypeMappingsTests {
}
@Nullable
private Method getConventionMapping(AnnotationTypeMapping mapping,
int attributeIndex) {
private Method getConventionMapping(AnnotationTypeMapping mapping, int attributeIndex) {
int mapped = mapping.getConventionMapping(attributeIndex);
return mapped != -1 ? mapping.getRoot().getAttributes().get(mapped) : null;
}
private AnnotationTypeMapping getMapping(AnnotationTypeMappings mappings,
Class<? extends Annotation> annotationType) {
for (AnnotationTypeMapping candidate : getAll(mappings)) {
if (candidate.getAnnotationType() == annotationType) {
return candidate;
@@ -544,89 +492,76 @@ class AnnotationTypeMappingsTests {
return map != null ? ((Map<String, ?>) map).get(attribute.getName()) : null;
}
@Retention(RetentionPolicy.RUNTIME)
@interface SimpleAnnotation {
}
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@UsesSunMisc
@interface WithSpringLangAnnotation {
}
@Retention(RetentionPolicy.RUNTIME)
@A
@B
@interface MetaAnnotated {
@interface AA {
}
@Retention(RetentionPolicy.RUNTIME)
@interface ABC {
}
@Retention(RetentionPolicy.RUNTIME)
@ABC
@interface AB {
}
@Retention(RetentionPolicy.RUNTIME)
@AA
@AB
@interface A {
}
@Retention(RetentionPolicy.RUNTIME)
@interface AA {
}
@Retention(RetentionPolicy.RUNTIME)
@ABC
@interface AB {
}
@Retention(RetentionPolicy.RUNTIME)
@interface ABC {
}
@Retention(RetentionPolicy.RUNTIME)
@interface B {
}
@Retention(RetentionPolicy.RUNTIME)
@Repeating
@Repeating
@interface WithRepeatedMetaAnnotations {
}
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Repeatings.class)
@interface Repeating {
@A
@B
@interface MetaAnnotated {
}
@Retention(RetentionPolicy.RUNTIME)
@interface Repeatings {
Repeating[] value();
}
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Repeatings.class)
@interface Repeating {
}
@Retention(RetentionPolicy.RUNTIME)
@Repeating
@Repeating
@interface WithRepeatedMetaAnnotations {
}
@Retention(RetentionPolicy.RUNTIME)
@SelfAnnotated
@interface SelfAnnotated {
}
@Retention(RetentionPolicy.RUNTIME)
@LoopB
@interface LoopA {
}
@Retention(RetentionPolicy.RUNTIME)
@LoopA
@interface LoopB {
}
@Retention(RetentionPolicy.RUNTIME)
@@ -634,7 +569,6 @@ class AnnotationTypeMappingsTests {
@AliasFor(value = "bar", attribute = "foo")
String test();
}
@Retention(RetentionPolicy.RUNTIME)
@@ -644,7 +578,12 @@ class AnnotationTypeMappingsTests {
String test() default "";
String other() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasForToOtherNonExistingAttributeTarget {
String other() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -653,14 +592,6 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = AliasForToOtherNonExistingAttributeTarget.class, attribute = "missing")
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasForToOtherNonExistingAttributeTarget {
String other() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -668,7 +599,12 @@ class AnnotationTypeMappingsTests {
@AliasFor("test")
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasForWithArrayCompatibleReturnTypesTarget {
String[] test() default {};
}
@Retention(RetentionPolicy.RUNTIME)
@@ -677,14 +613,12 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = AliasForWithArrayCompatibleReturnTypesTarget.class)
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasForWithArrayCompatibleReturnTypesTarget {
String[] test() default {};
@interface AliasForWithIncompatibleReturnTypesTarget {
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -692,14 +626,6 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = AliasForWithIncompatibleReturnTypesTarget.class)
String[] test() default {};
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasForWithIncompatibleReturnTypesTarget {
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -713,7 +639,6 @@ class AnnotationTypeMappingsTests {
@AliasFor("a")
String c() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -721,14 +646,12 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = AliasForNonMetaAnnotatedTarget.class)
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasForNonMetaAnnotatedTarget {
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -739,7 +662,6 @@ class AnnotationTypeMappingsTests {
@AliasFor("a")
String b() default "b";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -750,7 +672,12 @@ class AnnotationTypeMappingsTests {
@AliasFor("a")
String b();
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasWithExplicitMirrorAndDifferentDefaultsTarget {
String a() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -765,14 +692,14 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = AliasWithExplicitMirrorAndDifferentDefaultsTarget.class, attribute = "a")
String c() default "y";
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasWithExplicitMirrorAndDifferentDefaultsTarget {
@interface MappedTarget {
String a() default "";
String convention() default "";
String aliasTarget() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -783,16 +710,6 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = MappedTarget.class, attribute = "aliasTarget")
String alias() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface MappedTarget {
String convention() default "";
String aliasTarget() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -803,7 +720,16 @@ class AnnotationTypeMappingsTests {
@AliasFor("a")
String b() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface ImplicitMirrorsTarget {
@AliasFor("d")
String c() default "";
@AliasFor("c")
String d() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -815,18 +741,26 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = ImplicitMirrorsTarget.class, attribute = "c")
String b() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface ThreeDeepC {
String c1() default "";
String c2() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface ImplicitMirrorsTarget {
@ThreeDeepC
@interface ThreeDeepB {
@AliasFor("d")
String c() default "";
@AliasFor("c")
String d() default "";
@AliasFor(annotation = ThreeDeepC.class, attribute = "c1")
String b1() default "";
@AliasFor(annotation = ThreeDeepC.class, attribute = "c1")
String b2() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -847,37 +781,6 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = ThreeDeepC.class, attribute = "c2")
String a5() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@ThreeDeepC
@interface ThreeDeepB {
@AliasFor(annotation = ThreeDeepC.class, attribute = "c1")
String b1() default "";
@AliasFor(annotation = ThreeDeepC.class, attribute = "c1")
String b2() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface ThreeDeepC {
String c1() default "";
String c2() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@DefinedAttributesTarget(a = "test")
@interface DefinedAttributes {
@AliasFor(annotation = DefinedAttributesTarget.class, attribute = "b")
String value();
}
@Retention(RetentionPolicy.RUNTIME)
@@ -886,41 +789,44 @@ class AnnotationTypeMappingsTests {
String a();
String b() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@DefinedAttributesTarget(a = "test")
@interface DefinedAttributes {
@AliasFor(annotation = DefinedAttributesTarget.class, attribute = "b")
String value();
}
@AliasPair(a = "test")
static class WithAliasPairA {
}
@AliasPair(b = "test")
static class WithAliasPairB {
}
@AliasPair(a = "test", b = "test")
static class WithSameValueAliasPair {
}
@AliasPair(a = "test1", b = "test2")
static class WithDifferentValueAliasPair {
}
@AliasPair
static class WithDefaultValueAliasPair {
}
@Retention(RetentionPolicy.RUNTIME)
@MulipleRoutesToAliasB
@interface MulipleRoutesToAliasA {
@interface MulipleRoutesToAliasC {
@AliasFor(annotation = MulipleRoutesToAliasB.class, attribute = "b2")
String a1() default "";
@AliasFor("c2")
String c1() default "";
@AliasFor("c1")
String c2() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -935,26 +841,14 @@ class AnnotationTypeMappingsTests {
@AliasFor(annotation = MulipleRoutesToAliasC.class, attribute = "c1")
String b3() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface MulipleRoutesToAliasC {
@AliasFor("c2")
String c1() default "";
@AliasFor("c1")
String c2() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@ConventionToExplicitAliasesTarget
@interface ConventionToExplicitAliases {
String test() default "";
@MulipleRoutesToAliasB
@interface MulipleRoutesToAliasA {
@AliasFor(annotation = MulipleRoutesToAliasB.class, attribute = "b2")
String a1() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@@ -965,35 +859,37 @@ class AnnotationTypeMappingsTests {
@AliasFor("value")
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@ConventionToExplicitAliasesTarget
@interface ConventionToExplicitAliases {
String test() default "";
}
@Retention(RetentionPolicy.RUNTIME)
@interface ClassValue {
Class<?> value();
}
@Retention(RetentionPolicy.RUNTIME)
@interface ClassValueWithDefault {
Class<?> value() default InputStream.class;
}
@Retention(RetentionPolicy.RUNTIME)
@interface ClassArrayValueWithDefault {
Class<?>[] value() default { InputStream.class, OutputStream.class };
}
@Retention(RetentionPolicy.RUNTIME)
@interface NestedValue {
ClassValue value() default @ClassValue(InputStream.class);
}
}