1 16 17 package org.apache.commons.lang.mutable; 18 19 26 public class MutableByte extends Number implements Comparable , Mutable { 27 28 29 private static final long serialVersionUID = -1585823265L; 30 31 32 private byte value; 33 34 37 public MutableByte() { 38 super(); 39 } 40 41 47 public MutableByte(byte value) { 48 super(); 49 this.value = value; 50 } 51 52 60 public MutableByte(Number value) { 61 super(); 62 this.value = value.byteValue(); 63 } 64 65 71 public Object getValue() { 72 return new Byte (this.value); 73 } 74 75 81 public void setValue(byte value) { 82 this.value = value; 83 } 84 85 95 public void setValue(Object value) { 96 setValue(((Number ) value).byteValue()); 97 } 98 99 106 public byte byteValue() { 107 return value; 108 } 109 110 115 public int intValue() { 116 return value; 117 } 118 119 124 public long longValue() { 125 return value; 126 } 127 128 133 public float floatValue() { 134 return value; 135 } 136 137 142 public double doubleValue() { 143 return value; 144 } 145 146 156 public boolean equals(Object obj) { 157 if (obj instanceof MutableByte) { 158 return value == ((MutableByte) obj).byteValue(); 159 } 160 return false; 161 } 162 163 168 public int hashCode() { 169 return value; 170 } 171 172 180 public int compareTo(Object obj) { 181 MutableByte other = (MutableByte) obj; 182 byte anotherVal = other.value; 183 return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1); 184 } 185 186 191 public String toString() { 192 return String.valueOf(value); 193 } 194 195 } 196 | Popular Tags |