@@ -298,17 +298,36 @@ public static boolean containsAnnotation(List<Annotation> myListOfAnnotations, C
298298
299299 /**
300300 * @return Whether a given list of Annotation contains a certain annotation type.
301+ * @see #findAnnotation(Annotation[], Class)
301302 */
302- @ SuppressWarnings ({"WeakerAccess" , "unchecked" })
303- @ Nullable
304- public static <T extends Annotation > T findAnnotation (List <Annotation > myListOfAnnotations , Class <T > annotationClass ) {
305- for (Annotation annotation : myListOfAnnotations ) {
306- if (annotation .annotationType () == annotationClass ) {
307- return (T ) annotation ;
308- }
309- }
310- return null ;
303+ @ SuppressWarnings ("WeakerAccess" )
304+ public static boolean containsAnnotation (Annotation [] myListOfAnnotations , Class <? extends Annotation > annotationClass ) {
305+ return findAnnotation (myListOfAnnotations , annotationClass ) != null ;
311306 }
307+
308+ /**
309+ * @return Whether a given list of Annotation contains a certain annotation type.
310+ * @see #findAnnotation(Annotation[], Class)
311+ */
312+ @ SuppressWarnings ({"WeakerAccess" })
313+ @ Nullable
314+ public static <T extends Annotation > T findAnnotation (List <Annotation > myListOfAnnotations , Class <T > annotationClass ) {
315+ return findAnnotation (myListOfAnnotations .toArray (new Annotation [0 ]), annotationClass );
316+ }
317+
318+ /**
319+ * @return Whether a given list of Annotation contains a certain annotation type.
320+ */
321+ @ SuppressWarnings ({"WeakerAccess" , "unchecked" })
322+ @ Nullable
323+ public static <T extends Annotation > T findAnnotation (Annotation [] myListOfAnnotations , Class <T > annotationClass ) {
324+ for (Annotation annotation : myListOfAnnotations ) {
325+ if (annotation .annotationType () == annotationClass ) {
326+ return (T ) annotation ;
327+ }
328+ }
329+ return null ;
330+ }
312331
313332 /**
314333 * Shortcut helper method that replaces an item in an array and returns the array itself.
0 commit comments