1 3 package jodd.mutable; 4 5 8 public final class MutableShort extends Number implements Comparable { 9 10 11 public MutableShort() { 12 super(); 13 } 14 15 public MutableShort(short value) { 16 super(); 17 this.value = value; 18 } 19 20 public MutableShort(String value) { 21 this(Short.parseShort(value)); 22 } 23 24 26 29 public short value; 30 31 34 public short getValue() { 35 return value; 36 } 37 38 41 public void setValue(short value) { 42 this.value = value; 43 } 44 45 48 public void setValue(Number value) { 49 this.value = value.shortValue(); 50 } 51 52 54 57 public String toString() { 58 return Integer.toString(value); 59 } 60 61 64 public int hashCode() { 65 return value; 66 } 67 68 75 public boolean equals(Object obj) { 76 if (obj != null) { 77 if (obj instanceof Short ) { 78 return value == ((Short ) obj).shortValue(); 79 } 80 if (obj instanceof MutableShort) { 81 return value == ((MutableShort) obj).value; 82 } 83 } 84 return false; 85 } 86 87 89 92 public int intValue() { 93 return value; 94 } 95 96 99 public long longValue() { 100 return value; 101 } 102 103 106 public float floatValue() { 107 return value; 108 } 109 110 113 public double doubleValue() { 114 return value; 115 } 116 117 119 122 public int compareTo(Object obj) { 123 MutableShort other = (MutableShort) obj; 124 return value < other.value ? -1 : (value == other.value ? 0 : 1); 125 } 126 } | Popular Tags |