1 22 package org.jboss.beans.metadata.plugins; 23 24 import java.util.Iterator ; 25 import java.util.Set ; 26 import java.util.Collection ; 27 import java.util.Map ; 28 29 import org.jboss.beans.metadata.spi.AnnotationMetaData; 30 import org.jboss.beans.metadata.spi.FeatureMetaData; 31 import org.jboss.beans.metadata.spi.MetaDataVisitor; 32 import org.jboss.beans.metadata.spi.MetaDataVisitorNode; 33 import org.jboss.util.collection.CollectionsFactory; 34 import org.jboss.util.JBossObject; 35 import org.jboss.util.JBossStringBuilder; 36 37 43 public abstract class AbstractFeatureMetaData extends JBossObject implements FeatureMetaData, TypeProvider 44 { 45 46 protected String description; 47 48 49 protected Set <AnnotationMetaData> annotations; 50 51 54 public AbstractFeatureMetaData() 55 { 56 } 57 58 63 public void setDescription(String description) 64 { 65 this.description = description; 66 flushJBossObjectCache(); 67 } 68 69 74 public void setAnnotations(Set <AnnotationMetaData> annotations) 75 { 76 this.annotations = annotations; 77 flushJBossObjectCache(); 78 } 79 80 public String getDescription() 81 { 82 return description; 83 } 84 85 public Set <AnnotationMetaData> getAnnotations() 86 { 87 return annotations; 88 } 89 90 public void initialVisit(MetaDataVisitor visitor) 91 { 92 visitor.initialVisit(this); 93 } 94 95 public void describeVisit(MetaDataVisitor vistor) 96 { 97 vistor.describeVisit(this); 98 } 99 100 protected Class applyCollectionOrMapCheck(Class clazz) throws Throwable 101 { 102 if (Collection .class.isAssignableFrom(clazz) || Map .class.isAssignableFrom(clazz)) 104 { 105 throw new IllegalArgumentException ("Should not be here - set element/value class type in collection/map: " + this); 106 } 107 return clazz; 108 } 109 110 public Iterator <? extends MetaDataVisitorNode> getChildren() 111 { 112 Set <MetaDataVisitorNode> children = CollectionsFactory.createLazySet(); 113 addChildren(children); 114 if (children.size() == 0) 115 return null; 116 else 117 return children.iterator(); 118 } 119 120 protected void addChildren(Set <MetaDataVisitorNode> children) 121 { 122 if (annotations != null && annotations.size() > 0) 123 children.addAll(annotations); 124 } 125 126 public void toString(JBossStringBuilder buffer) 127 { 128 if (description != null) 129 buffer.append("description=").append(description); 130 if (annotations != null) 131 buffer.append(" annotations=").append(annotations); 132 } 133 134 public void toShortString(JBossStringBuilder buffer) 135 { 136 buffer.append(description); 137 } 138 } 139 | Popular Tags |