1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
30
30
31
31
import org .springframework .core .BridgeMethodResolver ;
32
32
import org .springframework .lang .Nullable ;
33
- import org .springframework .util .Assert ;
34
33
import org .springframework .util .LinkedMultiValueMap ;
35
34
import org .springframework .util .MultiValueMap ;
36
35
@@ -154,9 +153,6 @@ public Annotation[] getDeclaredAnnotations() {
154
153
* @see #hasMetaAnnotationTypes
155
154
*/
156
155
public static Set <String > getMetaAnnotationTypes (AnnotatedElement element , Class <? extends Annotation > annotationType ) {
157
- Assert .notNull (element , "AnnotatedElement must not be null" );
158
- Assert .notNull (annotationType , "'annotationType' must not be null" );
159
-
160
156
return getMetaAnnotationTypes (element , element .getAnnotation (annotationType ));
161
157
}
162
158
@@ -175,9 +171,6 @@ public static Set<String> getMetaAnnotationTypes(AnnotatedElement element, Class
175
171
* @see #hasMetaAnnotationTypes
176
172
*/
177
173
public static Set <String > getMetaAnnotationTypes (AnnotatedElement element , String annotationName ) {
178
- Assert .notNull (element , "AnnotatedElement must not be null" );
179
- Assert .hasLength (annotationName , "'annotationName' must not be null or empty" );
180
-
181
174
return getMetaAnnotationTypes (element , AnnotationUtils .getAnnotation (element , annotationName ));
182
175
}
183
176
@@ -217,9 +210,6 @@ public Object process(@Nullable AnnotatedElement annotatedElement, Annotation an
217
210
* @see #getMetaAnnotationTypes
218
211
*/
219
212
public static boolean hasMetaAnnotationTypes (AnnotatedElement element , Class <? extends Annotation > annotationType ) {
220
- Assert .notNull (element , "AnnotatedElement must not be null" );
221
- Assert .notNull (annotationType , "'annotationType' must not be null" );
222
-
223
213
return hasMetaAnnotationTypes (element , annotationType , null );
224
214
}
225
215
@@ -236,9 +226,6 @@ public static boolean hasMetaAnnotationTypes(AnnotatedElement element, Class<? e
236
226
* @see #getMetaAnnotationTypes
237
227
*/
238
228
public static boolean hasMetaAnnotationTypes (AnnotatedElement element , String annotationName ) {
239
- Assert .notNull (element , "AnnotatedElement must not be null" );
240
- Assert .hasLength (annotationName , "'annotationName' must not be null or empty" );
241
-
242
229
return hasMetaAnnotationTypes (element , null , annotationName );
243
230
}
244
231
@@ -271,14 +258,10 @@ public Boolean process(@Nullable AnnotatedElement annotatedElement, Annotation a
271
258
* @see #hasAnnotation(AnnotatedElement, Class)
272
259
*/
273
260
public static boolean isAnnotated (AnnotatedElement element , Class <? extends Annotation > annotationType ) {
274
- Assert .notNull (element , "AnnotatedElement must not be null" );
275
- Assert .notNull (annotationType , "'annotationType' must not be null" );
276
-
277
261
// Shortcut: directly present on the element, with no processing needed?
278
262
if (element .isAnnotationPresent (annotationType )) {
279
263
return true ;
280
264
}
281
-
282
265
return Boolean .TRUE .equals (searchWithGetSemantics (element , annotationType , null , alwaysTrueAnnotationProcessor ));
283
266
}
284
267
@@ -295,9 +278,6 @@ public static boolean isAnnotated(AnnotatedElement element, Class<? extends Anno
295
278
* @return {@code true} if a matching annotation is present
296
279
*/
297
280
public static boolean isAnnotated (AnnotatedElement element , String annotationName ) {
298
- Assert .notNull (element , "AnnotatedElement must not be null" );
299
- Assert .hasLength (annotationName , "'annotationName' must not be null or empty" );
300
-
301
281
return Boolean .TRUE .equals (searchWithGetSemantics (element , null , annotationName , alwaysTrueAnnotationProcessor ));
302
282
}
303
283
@@ -322,7 +302,6 @@ public static boolean isAnnotated(AnnotatedElement element, String annotationNam
322
302
public static AnnotationAttributes getMergedAnnotationAttributes (
323
303
AnnotatedElement element , Class <? extends Annotation > annotationType ) {
324
304
325
- Assert .notNull (annotationType , "'annotationType' must not be null" );
326
305
AnnotationAttributes attributes = searchWithGetSemantics (element , annotationType , null ,
327
306
new MergedAnnotationAttributesProcessor ());
328
307
AnnotationUtils .postProcessAnnotationAttributes (element , attributes , false , false );
@@ -382,7 +361,6 @@ public static AnnotationAttributes getMergedAnnotationAttributes(AnnotatedElemen
382
361
public static AnnotationAttributes getMergedAnnotationAttributes (AnnotatedElement element ,
383
362
String annotationName , boolean classValuesAsString , boolean nestedAnnotationsAsMap ) {
384
363
385
- Assert .hasLength (annotationName , "'annotationName' must not be null or empty" );
386
364
AnnotationAttributes attributes = searchWithGetSemantics (element , null , annotationName ,
387
365
new MergedAnnotationAttributesProcessor (classValuesAsString , nestedAnnotationsAsMap ));
388
366
AnnotationUtils .postProcessAnnotationAttributes (element , attributes , classValuesAsString , nestedAnnotationsAsMap );
@@ -409,8 +387,6 @@ public static AnnotationAttributes getMergedAnnotationAttributes(AnnotatedElemen
409
387
*/
410
388
@ Nullable
411
389
public static <A extends Annotation > A getMergedAnnotation (AnnotatedElement element , Class <A > annotationType ) {
412
- Assert .notNull (annotationType , "'annotationType' must not be null" );
413
-
414
390
// Shortcut: directly present on the element, with no merging needed?
415
391
if (!(element instanceof Class )) {
416
392
// Do not use this shortcut against a Class: Inherited annotations
@@ -446,12 +422,7 @@ public static <A extends Annotation> A getMergedAnnotation(AnnotatedElement elem
446
422
* @see #getAllAnnotationAttributes(AnnotatedElement, String)
447
423
* @see #findAllMergedAnnotations(AnnotatedElement, Class)
448
424
*/
449
- public static <A extends Annotation > Set <A > getAllMergedAnnotations (AnnotatedElement element ,
450
- Class <A > annotationType ) {
451
-
452
- Assert .notNull (element , "AnnotatedElement must not be null" );
453
- Assert .notNull (annotationType , "'annotationType' must not be null" );
454
-
425
+ public static <A extends Annotation > Set <A > getAllMergedAnnotations (AnnotatedElement element , Class <A > annotationType ) {
455
426
MergedAnnotationAttributesProcessor processor = new MergedAnnotationAttributesProcessor (false , false , true );
456
427
searchWithGetSemantics (element , annotationType , null , processor );
457
428
return postProcessAndSynthesizeAggregatedResults (element , annotationType , processor .getAggregatedResults ());
@@ -516,9 +487,6 @@ public static <A extends Annotation> Set<A> getMergedRepeatableAnnotations(Annot
516
487
public static <A extends Annotation > Set <A > getMergedRepeatableAnnotations (AnnotatedElement element ,
517
488
Class <A > annotationType , @ Nullable Class <? extends Annotation > containerType ) {
518
489
519
- Assert .notNull (element , "AnnotatedElement must not be null" );
520
- Assert .notNull (annotationType , "'annotationType' must not be null" );
521
-
522
490
if (containerType == null ) {
523
491
containerType = resolveContainerType (annotationType );
524
492
}
@@ -603,14 +571,10 @@ public Object process(@Nullable AnnotatedElement annotatedElement, Annotation an
603
571
* @see #isAnnotated(AnnotatedElement, Class)
604
572
*/
605
573
public static boolean hasAnnotation (AnnotatedElement element , Class <? extends Annotation > annotationType ) {
606
- Assert .notNull (element , "AnnotatedElement must not be null" );
607
- Assert .notNull (annotationType , "'annotationType' must not be null" );
608
-
609
574
// Shortcut: directly present on the element, with no processing needed?
610
575
if (element .isAnnotationPresent (annotationType )) {
611
576
return true ;
612
577
}
613
-
614
578
return Boolean .TRUE .equals (searchWithFindSemantics (element , annotationType , null , alwaysTrueAnnotationProcessor ));
615
579
}
616
580
@@ -710,8 +674,6 @@ public static AnnotationAttributes findMergedAnnotationAttributes(AnnotatedEleme
710
674
*/
711
675
@ Nullable
712
676
public static <A extends Annotation > A findMergedAnnotation (AnnotatedElement element , Class <A > annotationType ) {
713
- Assert .notNull (annotationType , "'annotationType' must not be null" );
714
-
715
677
// Shortcut: directly present on the element, with no merging needed?
716
678
if (!(element instanceof Class )) {
717
679
// Do not use this shortcut against a Class: Inherited annotations
@@ -746,12 +708,7 @@ public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement ele
746
708
* @see #findMergedAnnotation(AnnotatedElement, Class)
747
709
* @see #getAllMergedAnnotations(AnnotatedElement, Class)
748
710
*/
749
- public static <A extends Annotation > Set <A > findAllMergedAnnotations (AnnotatedElement element ,
750
- Class <A > annotationType ) {
751
-
752
- Assert .notNull (element , "AnnotatedElement must not be null" );
753
- Assert .notNull (annotationType , "'annotationType' must not be null" );
754
-
711
+ public static <A extends Annotation > Set <A > findAllMergedAnnotations (AnnotatedElement element , Class <A > annotationType ) {
755
712
MergedAnnotationAttributesProcessor processor = new MergedAnnotationAttributesProcessor (false , false , true );
756
713
searchWithFindSemantics (element , annotationType , null , processor );
757
714
return postProcessAndSynthesizeAggregatedResults (element , annotationType , processor .getAggregatedResults ());
@@ -816,9 +773,6 @@ public static <A extends Annotation> Set<A> findMergedRepeatableAnnotations(Anno
816
773
public static <A extends Annotation > Set <A > findMergedRepeatableAnnotations (AnnotatedElement element ,
817
774
Class <A > annotationType , @ Nullable Class <? extends Annotation > containerType ) {
818
775
819
- Assert .notNull (element , "AnnotatedElement must not be null" );
820
- Assert .notNull (annotationType , "'annotationType' must not be null" );
821
-
822
776
if (containerType == null ) {
823
777
containerType = resolveContainerType (annotationType );
824
778
}
@@ -902,8 +856,6 @@ private static <T> T searchWithGetSemantics(AnnotatedElement element,
902
856
@ Nullable Class <? extends Annotation > containerType , Processor <T > processor ,
903
857
Set <AnnotatedElement > visited , int metaDepth ) {
904
858
905
- Assert .notNull (element , "AnnotatedElement must not be null" );
906
-
907
859
if (visited .add (element )) {
908
860
try {
909
861
// Start searching within locally declared annotations
@@ -1096,8 +1048,6 @@ private static <T> T searchWithFindSemantics(AnnotatedElement element,
1096
1048
@ Nullable Class <? extends Annotation > containerType , Processor <T > processor ,
1097
1049
Set <AnnotatedElement > visited , int metaDepth ) {
1098
1050
1099
- Assert .notNull (element , "AnnotatedElement must not be null" );
1100
-
1101
1051
if (visited .add (element )) {
1102
1052
try {
1103
1053
// Locally declared annotations (ignoring @Inherited)
0 commit comments