@@ -22,7 +22,7 @@ public ValueType getValueType() {
2222 }
2323 @ Override
2424 public void writeTo (MessagePacker packer ) throws IOException {
25- switch (tpe ) {
25+ switch (type ) {
2626 case BIG_INTEGER :
2727 packer .packBigInteger (biValue );
2828 break ;
@@ -44,7 +44,7 @@ public void accept(ValueVisitor visitor) {
4444
4545 @ Override
4646 public IntegerValue toValue () {
47- switch (tpe ){
47+ switch (type ){
4848 case BYTE :
4949 return ValueFactory .newByte (toByte ());
5050 case SHORT :
@@ -68,32 +68,32 @@ public static enum Type {
6868 BIG_INTEGER
6969 }
7070
71- private Type tpe ;
71+ private Type type ;
7272 private long longValue ;
7373 private BigInteger biValue ;
7474
7575 public Type getType () {
76- return tpe ;
76+ return type ;
7777 }
7878
7979 public void setByte (byte v ){
80- tpe = Type .BYTE ;
80+ type = Type .BYTE ;
8181 longValue = v ;
8282 }
8383 public void setShort (short v ) {
84- tpe = Type .SHORT ;
84+ type = Type .SHORT ;
8585 longValue = v ;
8686 }
8787 public void setInt (int v ) {
88- tpe = Type .INT ;
88+ type = Type .INT ;
8989 longValue = v ;
9090 }
9191 public void setLong (long v ) {
92- tpe = Type .LONG ;
92+ type = Type .LONG ;
9393 longValue = v ;
9494 }
9595 public void setBigInteger (BigInteger v ) {
96- tpe = Type .BIG_INTEGER ;
96+ type = Type .BIG_INTEGER ;
9797 biValue = v ;
9898 }
9999
@@ -102,47 +102,52 @@ private RuntimeException failure() {
102102 }
103103
104104 public boolean isBigInteger () {
105- return tpe == Type .BIG_INTEGER ;
105+ return type == Type .BIG_INTEGER ;
106106 }
107107
108108 @ Override
109109 public boolean isValidByte () {
110- return tpe == Type .BYTE ;
110+ return type == Type .BYTE ;
111111 }
112112 @ Override
113113 public boolean isValidShort () {
114- return tpe .ordinal () <= Type .SHORT .ordinal ();
114+ return type .ordinal () <= Type .SHORT .ordinal ();
115115 }
116116 @ Override
117117 public boolean isValidInt () {
118- return tpe .ordinal () <= Type .INT .ordinal ();
118+ return type .ordinal () <= Type .INT .ordinal ();
119119 }
120120 @ Override
121121 public boolean isValidLong () {
122- return tpe .ordinal () <= Type .LONG .ordinal ();
122+ return type .ordinal () <= Type .LONG .ordinal ();
123123 }
124124
125125 @ Override
126126 public boolean isWhole () {
127127 return true ;
128128 }
129129
130+ @ Override
130131 public byte toByte () {
131132 return isBigInteger () ? biValue .byteValue () : (byte ) longValue ;
132133 }
133134
135+ @ Override
134136 public short toShort () {
135137 return isBigInteger () ? biValue .shortValue () : (short ) longValue ;
136138 }
137139
140+ @ Override
138141 public int toInt () {
139142 return isBigInteger () ? biValue .intValue () : (int ) longValue ;
140143 }
141144
145+ @ Override
142146 public long toLong (){
143147 return isBigInteger () ? biValue .longValue () : longValue ;
144148 }
145149
150+ @ Override
146151 public BigInteger toBigInteger () {
147152 return isBigInteger () ? biValue : BigInteger .valueOf (longValue );
148153 }
@@ -158,7 +163,7 @@ public double toDouble() {
158163
159164 @ Override
160165 public byte asByte () throws MessageIntegerOverflowException {
161- switch (tpe ) {
166+ switch (type ) {
162167 case BYTE :
163168 return (byte ) longValue ;
164169 case SHORT :
@@ -185,7 +190,7 @@ public byte asByte() throws MessageIntegerOverflowException {
185190
186191 @ Override
187192 public short asShort () throws MessageIntegerOverflowException {
188- switch (tpe ) {
193+ switch (type ) {
189194 case BYTE :
190195 case SHORT :
191196 return (short ) longValue ;
@@ -212,7 +217,7 @@ public short asShort() throws MessageIntegerOverflowException {
212217
213218 @ Override
214219 public int asInt () throws MessageIntegerOverflowException {
215- switch (tpe ) {
220+ switch (type ) {
216221 case BYTE :
217222 case SHORT :
218223 case INT :
@@ -256,7 +261,14 @@ public BigInteger asBigInteger() {
256261
257262 @ Override
258263 public int hashCode () {
259- return isBigInteger () ? biValue .hashCode () : (int ) longValue ;
264+ int hash = 0 ;
265+ if (isBigInteger ()) {
266+ hash = biValue .hashCode ();
267+ }
268+ else {
269+ hash = (int )((longValue >>> 32 ) * 31 + longValue & 0xFFFFFFFF );
270+ }
271+ return hash ;
260272 }
261273
262274 @ Override
0 commit comments