1 22 package org.jboss.metadata.generic; 23 24 import java.lang.annotation.Annotation ; 25 26 import org.jboss.metadata.spi.retrieval.MetaDataItem; 27 28 34 public final class GenericMatcher 35 { 36 43 @SuppressWarnings ("unchecked") 44 public static final Object matchObject(Object [] objects, String name) 45 { 46 if (objects != null) 47 { 48 for (Object o : objects) 49 { 50 if (o instanceof Annotation ) 51 { 52 Annotation a = (Annotation ) o; 53 if (name.equals(a.annotationType().getName())) 54 return o; 55 } 56 else if (name.equals(o.getClass().getName())) 57 return o; 58 } 59 } 60 61 return null; 62 } 63 64 71 public static final MetaDataItem matchMetaDataItem(MetaDataItem[] metaDatas, String name) 72 { 73 if (metaDatas != null) 74 { 75 for (MetaDataItem item : metaDatas) 76 { 77 Object o = item.getValue(); 78 if (o instanceof Annotation ) 79 { 80 Annotation a = (Annotation ) o; 81 if (name.equals(a.annotationType().getName())) 82 return item; 83 } 84 else if (name.equals(item.getName())) 85 return item; 86 } 87 } 88 89 return null; 90 } 91 } 92 | Popular Tags |