1 22 package org.jboss.reflect.plugins; 23 24 import java.lang.reflect.Modifier ; 25 26 import org.jboss.reflect.spi.AnnotationValue; 27 import org.jboss.reflect.spi.ClassInfo; 28 import org.jboss.reflect.spi.FieldInfo; 29 import org.jboss.reflect.spi.TypeInfo; 30 import org.jboss.util.JBossStringBuilder; 31 import org.jboss.util.NotImplementedException; 32 33 39 public class FieldInfoImpl extends AnnotationHolder implements FieldInfo 40 { 41 42 private static final long serialVersionUID = 3546084661584539959L; 43 44 45 protected String name; 46 47 48 protected TypeInfo type; 49 50 51 protected int modifiers; 52 53 54 protected ClassInfo declaringClass; 55 56 57 protected int hash = -1; 58 59 62 public FieldInfoImpl() 63 { 64 } 65 66 75 public FieldInfoImpl(AnnotationValue[] annotations, String name, TypeInfo type, int modifiers, ClassInfo declaring) 76 { 77 super(annotations); 78 this.name = name; 79 this.type = type; 80 this.modifiers = modifiers; 81 this.declaringClass = declaring; 82 calculateHash(); 83 } 84 85 public String getName() 86 { 87 return name; 88 } 89 90 public TypeInfo getType() 91 { 92 return type; 93 } 94 95 public ClassInfo getDeclaringClass() 96 { 97 return declaringClass; 98 } 99 100 public int getModifiers() 101 { 102 return modifiers; 103 } 104 105 public boolean isStatic() 106 { 107 return Modifier.isStatic(modifiers); 108 } 109 110 public boolean isPublic() 111 { 112 return Modifier.isPublic(modifiers); 113 } 114 115 public Object get(Object target) throws Throwable 116 { 117 throw new NotImplementedException("get"); 118 } 119 120 public Object set(Object target, Object value) throws Throwable 121 { 122 throw new NotImplementedException("set"); 123 } 124 125 protected void toString(JBossStringBuilder buffer) 126 { 127 buffer.append("name=").append(name); 128 } 129 130 public boolean equals(Object obj) 131 { 132 if (this == obj) return true; 133 if (obj == null || obj instanceof FieldInfo == false) 134 return false; 135 136 final FieldInfo other = (FieldInfo) obj; 137 138 if (name.equals(other.getName()) == false) 139 return false; 140 return declaringClass.equals(other.getDeclaringClass()); 141 } 142 143 public int hashCode() 144 { 145 return hash; 146 } 147 148 151 protected void calculateHash() 152 { 153 hash = name.hashCode(); 154 } 155 } 156 | Popular Tags |