1 22 package org.jboss.metadata.annotation; 23 24 import java.lang.annotation.Annotation ; 25 26 import org.jboss.metadata.spi.retrieval.AnnotationItem; 27 28 34 public final class AnnotationMatcher 35 { 36 44 @SuppressWarnings ("unchecked") 45 public static final <T extends Annotation > T matchAnnotation(Annotation [] annotations, Class <T> annotationType) 46 { 47 if (annotations != null) 48 { 49 for (Annotation a : annotations) 50 { 51 if (annotationType.equals(a.annotationType())) 52 return (T) a; 53 } 54 } 55 56 return null; 57 } 58 59 67 @SuppressWarnings ("unchecked") 68 public static final <T extends Annotation > AnnotationItem<T> matchAnnotationItem(AnnotationItem[] annotations, Class <T> annotationType) 69 { 70 if (annotations != null) 71 { 72 for (AnnotationItem item : annotations) 73 { 74 Annotation a = item.getAnnotation(); 75 if (annotationType.equals(a.annotationType())) 76 return item; 77 } 78 } 79 80 return null; 81 } 82 } 83 | Popular Tags |