Here you can find the source of getAnnotation(Annotation[] annotaions, Class extends Annotation> T)
Parameter | Description |
---|---|
T | a parameter |
annotaions | a parameter |
@SuppressWarnings("unchecked") public static <T> T getAnnotation(Annotation[] annotaions, Class<? extends Annotation> T)
//package com.java2s; //License from project: Apache License import java.lang.annotation.Annotation; public class Main { /**//from w w w.j a v a 2 s .co m * find an annotation from an array * * @param <T> * @param annotaions * @param T * @return */ @SuppressWarnings("unchecked") public static <T> T getAnnotation(Annotation[] annotaions, Class<? extends Annotation> T) { for (int i = 0; i < annotaions.length; i++) { if (annotaions[i].annotationType().equals(T)) { return (T) annotaions[i]; } } return null; } }