@@ -164,6 +164,7 @@ public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsin
164
164
assertMultipleAnnotationsWithIdenticalAttributeNames (metadata );
165
165
}
166
166
167
+
167
168
private void assertMultipleAnnotationsWithIdenticalAttributeNames (AnnotationMetadata metadata ) {
168
169
AnnotationAttributes attributes1 = (AnnotationAttributes ) metadata .getAnnotationAttributes (
169
170
NamedAnnotation1 .class .getName (), false );
@@ -211,6 +212,8 @@ private void doTestAnnotationInfo(AnnotationMetadata metadata) {
211
212
assertEquals ("direct" , method .getAnnotationAttributes (DirectAnnotation .class .getName ()).get ("value" ));
212
213
List <Object > allMeta = method .getAllAnnotationAttributes (DirectAnnotation .class .getName ()).get ("value" );
213
214
assertThat (new HashSet <Object >(allMeta ), is (equalTo (new HashSet <Object >(Arrays .asList ("direct" , "meta" )))));
215
+ allMeta = method .getAllAnnotationAttributes (DirectAnnotation .class .getName ()).get ("additional" );
216
+ assertThat (new HashSet <Object >(allMeta ), is (equalTo (new HashSet <Object >(Arrays .asList ("direct" )))));
214
217
215
218
assertTrue (metadata .isAnnotated (IsAnnotatedAnnotation .class .getName ()));
216
219
@@ -251,6 +254,8 @@ private void doTestAnnotationInfo(AnnotationMetadata metadata) {
251
254
assertEquals ("direct" , metadata .getAnnotationAttributes (DirectAnnotation .class .getName ()).get ("value" ));
252
255
allMeta = metadata .getAllAnnotationAttributes (DirectAnnotation .class .getName ()).get ("value" );
253
256
assertThat (new HashSet <Object >(allMeta ), is (equalTo (new HashSet <Object >(Arrays .asList ("direct" , "meta" )))));
257
+ allMeta = metadata .getAllAnnotationAttributes (DirectAnnotation .class .getName ()).get ("additional" );
258
+ assertThat (new HashSet <Object >(allMeta ), is (equalTo (new HashSet <Object >(Arrays .asList ("direct" )))));
254
259
}
255
260
{ // perform tests with classValuesAsString = true
256
261
AnnotationAttributes specialAttrs = (AnnotationAttributes ) metadata .getAnnotationAttributes (
@@ -341,14 +346,16 @@ public static enum SomeEnum {
341
346
NestedAnno [] optionalArray () default { @ NestedAnno (value = "optional" , anEnum = SomeEnum .DEFAULT , classArray = Void .class ) };
342
347
}
343
348
344
- @ Target ({ ElementType .TYPE , ElementType .METHOD })
349
+ @ Target ({ElementType .TYPE , ElementType .METHOD })
345
350
@ Retention (RetentionPolicy .RUNTIME )
346
351
public @interface DirectAnnotation {
347
352
348
353
String value ();
354
+
355
+ String additional () default "direct" ;
349
356
}
350
357
351
- @ Target ({ ElementType .TYPE } )
358
+ @ Target (ElementType .TYPE )
352
359
@ Retention (RetentionPolicy .RUNTIME )
353
360
public @interface IsAnnotatedAnnotation {
354
361
}
@@ -358,9 +365,11 @@ public static enum SomeEnum {
358
365
@ DirectAnnotation ("meta" )
359
366
@ IsAnnotatedAnnotation
360
367
public @interface MetaAnnotation {
368
+
369
+ String additional () default "meta" ;
361
370
}
362
371
363
- @ Target ({ ElementType .TYPE , ElementType .METHOD })
372
+ @ Target ({ElementType .TYPE , ElementType .METHOD })
364
373
@ Retention (RetentionPolicy .RUNTIME )
365
374
@ MetaAnnotation
366
375
public @interface MetaMetaAnnotation {
@@ -380,17 +389,18 @@ public static enum SubclassEnum {
380
389
},
381
390
BAR {
382
391
/* Do not delete! This subclassing is intentional. */
383
- };
392
+ }
384
393
}
385
394
386
395
@ Component ("myName" )
387
396
@ Scope ("myScope" )
388
- @ SpecialAttr (clazz = String .class , state = Thread .State .NEW , nestedAnno = @ NestedAnno (value = "na" , anEnum = SomeEnum .LABEL1 , classArray = { String .class }), nestedAnnoArray = {
389
- @ NestedAnno , @ NestedAnno (value = "na1" , anEnum = SomeEnum .LABEL2 , classArray = { Number .class }) })
390
- @ SuppressWarnings ({ "serial" , "unused" })
397
+ @ SpecialAttr (clazz = String .class , state = Thread .State .NEW ,
398
+ nestedAnno = @ NestedAnno (value = "na" , anEnum = SomeEnum .LABEL1 , classArray = {String .class }),
399
+ nestedAnnoArray = {@ NestedAnno , @ NestedAnno (value = "na1" , anEnum = SomeEnum .LABEL2 , classArray = {Number .class })})
400
+ @ SuppressWarnings ({"serial" , "unused" })
391
401
@ DirectAnnotation ("direct" )
392
402
@ MetaMetaAnnotation
393
- @ EnumSubclasses ({ SubclassEnum .FOO , SubclassEnum .BAR })
403
+ @ EnumSubclasses ({SubclassEnum .FOO , SubclassEnum .BAR })
394
404
private static class AnnotatedComponent implements Serializable {
395
405
396
406
@ TestAutowired
@@ -406,9 +416,8 @@ public void meta() {
406
416
}
407
417
}
408
418
409
- @ SuppressWarnings ({ "serial" } )
419
+ @ SuppressWarnings ("serial" )
410
420
private static class AnnotatedComponentSubClass extends AnnotatedComponent {
411
-
412
421
}
413
422
414
423
@ Target (ElementType .TYPE )
0 commit comments