1 22 package org.jboss.reflect.plugins; 23 24 import org.jboss.reflect.spi.AnnotatedInfo; 25 import org.jboss.reflect.spi.AnnotationValue; 26 import org.jboss.reflect.spi.ArrayInfo; 27 import org.jboss.reflect.spi.TypeInfo; 28 29 35 public class ArrayInfoImpl extends ClassInfoImpl implements ArrayInfo 36 { 37 38 private static final long serialVersionUID = 3905804162787980599L; 39 40 41 protected TypeInfo componentType; 42 43 44 protected int hash = -1; 45 46 49 public ArrayInfoImpl() 50 { 51 } 52 53 58 public ArrayInfoImpl(TypeInfo componentType) 59 { 60 this.componentType = componentType; 61 calculateHash(); 62 } 63 64 public TypeInfo getComponentType() 65 { 66 return componentType; 67 } 68 69 public String getName() 70 { 71 return "[L" + componentType.getName() + ";"; 72 } 73 74 public AnnotationValue getAnnotation(String name) 75 { 76 if (componentType instanceof AnnotatedInfo) 77 { 78 return ((AnnotatedInfo)componentType).getAnnotation(name); 79 } 80 else 81 { 82 return null; 83 } 84 } 85 86 public AnnotationValue[] getAnnotations() 87 { 88 if (componentType instanceof AnnotatedInfo) 89 { 90 return ((AnnotatedInfo)componentType).getAnnotations(); 91 } 92 else 93 { 94 return UNKNOWN_ANNOTATIONS; 95 } 96 } 97 98 public boolean isAnnotationPresent(String name) 99 { 100 if (componentType instanceof AnnotatedInfo) 101 { 102 return ((AnnotatedInfo)componentType).isAnnotationPresent(name); 103 } 104 else 105 { 106 return false; 107 } 108 } 109 110 public boolean equals(Object o) 111 { 112 if (this == o) return true; 113 if (!(o instanceof ArrayInfoImpl)) return false; 114 if (!super.equals(o)) return false; 115 116 final ArrayInfoImpl arrayInfo = (ArrayInfoImpl) o; 117 118 if (!componentType.equals(arrayInfo.componentType)) return false; 119 120 return true; 121 } 122 123 public int hashCode() { return hash; } 124 125 128 protected void calculateHash() 129 { 130 int result = super.hashCode(); 131 result = 29 * result + componentType.hashCode(); 132 hash = result; 133 } 134 } 135 | Popular Tags |