1 22 package org.jboss.metadata.spi.retrieval.basic; 23 24 import java.lang.annotation.Annotation ; 25 26 import org.jboss.metadata.spi.MetaData; 27 import org.jboss.metadata.spi.loader.MetaDataLoader; 28 import org.jboss.metadata.spi.retrieval.AnnotationItem; 29 import org.jboss.metadata.spi.retrieval.AnnotationsItem; 30 31 37 public class BasicAnnotationsItem extends BasicItem<Annotation []> implements AnnotationsItem 38 { 39 40 private AnnotationItem[] annotationItems; 41 42 43 private Annotation [] annotations; 44 45 51 public BasicAnnotationsItem(MetaDataLoader loader, AnnotationItem[] annotationItems) 52 { 53 super(loader); 54 55 if (annotationItems == null) 56 throw new IllegalArgumentException ("Null annotation items"); 57 58 this.annotationItems = annotationItems; 59 60 if (annotationItems.length == 0) 61 annotations = MetaData.NO_ANNOTATIONS; 62 } 63 64 public Annotation [] getValue() 65 { 66 if (annotations == null) 67 { 68 Annotation [] temp = new Annotation [annotationItems.length]; 69 for (int i = 0; i < temp.length; ++i) 70 temp[i] = annotationItems[i].getAnnotation(); 71 annotations = temp; 72 } 73 return annotations; 74 } 75 76 public AnnotationItem[] getAnnotations() 77 { 78 return annotationItems; 79 } 80 81 public boolean isCachable() 82 { 83 if (super.isCachable() == false) 84 return false; 85 86 for (AnnotationItem item : annotationItems) 87 { 88 if (item.isCachable() == false) 89 return false; 90 } 91 92 return true; 93 } 94 95 public boolean isValid() 96 { 97 if (super.isValid() == false) 98 return false; 99 100 for (AnnotationItem item : annotationItems) 101 { 102 if (item.isValid() == false) 103 return false; 104 } 105 106 return true; 107 } 108 } 109 | Popular Tags |