1 22 package org.jboss.metadata.spi.retrieval.simple; 23 24 import java.lang.annotation.Annotation ; 25 26 import org.jboss.metadata.spi.MetaData; 27 import org.jboss.metadata.spi.retrieval.AnnotationItem; 28 import org.jboss.metadata.spi.retrieval.AnnotationsItem; 29 30 36 public class SimpleAnnotationsItem extends SimpleItem<Annotation []> implements AnnotationsItem 37 { 38 39 public static final SimpleAnnotationsItem NO_ANNOTATIONS = new SimpleAnnotationsItem(); 40 41 42 private AnnotationItem[] annotationItems; 43 44 45 private Annotation [] annotations; 46 47 50 protected SimpleAnnotationsItem() 51 { 52 this(NO_ANNOTATION_ITEMS); 53 } 54 55 60 public SimpleAnnotationsItem(AnnotationItem[] annotationItems) 61 { 62 setAnnotationItems(annotationItems); 63 } 64 65 public Annotation [] getValue() 66 { 67 if (annotations == null) 68 { 69 Annotation [] temp = new Annotation [annotationItems.length]; 70 for (int i = 0; i < temp.length; ++i) 71 temp[i] = annotationItems[i].getAnnotation(); 72 annotations = temp; 73 } 74 return annotations; 75 } 76 77 public AnnotationItem[] getAnnotations() 78 { 79 return annotationItems; 80 } 81 82 87 protected void setAnnotationItems(AnnotationItem[] annotationItems) 88 { 89 if (annotationItems == null) 90 throw new IllegalArgumentException ("Null annotation items"); 91 92 this.annotationItems = annotationItems; 93 if (annotationItems.length == 0) 94 annotations = MetaData.NO_ANNOTATIONS; 95 else 96 annotations = null; 97 } 98 } 99 | Popular Tags |