1 3 package jodd.mutable; 4 5 8 public final class MutableLong extends Number implements Comparable { 9 10 11 public MutableLong() { 12 super(); 13 } 14 15 public MutableLong(long value) { 16 super(); 17 this.value = value; 18 } 19 20 public MutableLong(String value) { 21 this(Long.parseLong(value)); 22 } 23 24 26 29 public long value; 30 31 34 public long getValue() { 35 return value; 36 } 37 38 41 public void setValue(long value) { 42 this.value = value; 43 } 44 45 48 public void setValue(Number value) { 49 this.value = value.longValue(); 50 } 51 52 54 57 public String toString() { 58 return Long.toString(value); 59 } 60 61 64 public int hashCode() { 65 return (int) (value ^ (value >>> 32)); 66 } 67 68 75 public boolean equals(Object obj) { 76 if (obj != null) { 77 if (obj instanceof Long ) { 78 return value == ((Long ) obj).longValue(); 79 } 80 if (obj instanceof MutableLong) { 81 return value == ((MutableLong) obj).value; 82 } 83 } 84 return false; 85 } 86 87 89 92 public int intValue() { 93 return (int) 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 MutableLong other = (MutableLong) obj; 124 return value < other.value ? -1 : (value == other.value ? 0 : 1); 125 } 126 } | Popular Tags |