Here you can find the source of getAnnotationByType(List
public static Annotation getAnnotationByType(List<Annotation> annotations, Class<?> annotationType)
//package com.java2s; /*// www . j a v a2 s. co m * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. * * Copyright (c) 2014, Gluu */ import java.lang.annotation.Annotation; import java.util.List; public class Main { public static final Annotation[] NO_ANNOTATIONS = new Annotation[0]; public static Annotation getAnnotationByType(List<Annotation> annotations, Class<?> annotationType) { if (annotations == null) { return null; } return getAnnotationByType(annotations.toArray(NO_ANNOTATIONS), annotationType); } public static Annotation getAnnotationByType(Annotation[] annotations, Class<?> annotationType) { for (Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return annotation; } } return null; } }