1 22 package org.jboss.reflect.plugins; 23 24 import java.io.Serializable ; 25 import java.util.Arrays ; 26 27 import org.jboss.reflect.spi.ArrayValue; 28 import org.jboss.reflect.spi.TypeInfo; 29 import org.jboss.reflect.spi.Value; 30 import org.jboss.util.JBossObject; 31 32 38 public class ArrayValueImpl extends JBossObject implements ArrayValue, Serializable 39 { 40 41 private static final long serialVersionUID = 3979266949899367475L; 42 43 44 protected TypeInfo type; 45 46 47 protected Value[] values; 48 49 50 protected int hash = -1; 51 52 55 public ArrayValueImpl() 56 { 57 } 58 59 65 public ArrayValueImpl(TypeInfo type, Value[] values) 66 { 67 this.type = type; 68 this.values = values; 69 calculateHash(); 70 71 } 72 73 public Value[] getValues() 74 { 75 return values; 76 } 77 78 public TypeInfo getType() 79 { 80 return type; 81 } 82 83 public boolean equals(Object o) 84 { 85 if (this == o) return true; 86 if (!(o instanceof ArrayValueImpl)) return false; 87 88 final ArrayValueImpl arrayValue = (ArrayValueImpl) o; 89 90 if (!type.equals(arrayValue.type)) return false; 91 if (!Arrays.equals(values, arrayValue.values)) return false; 92 93 return true; 94 } 95 96 public int hashCode() 97 { 98 return hash; 99 } 100 101 104 protected void calculateHash() 105 { 106 hash = hash * 29 + type.hashCode(); 108 } 109 } 110 | Popular Tags |