1 16 17 package org.apache.commons.lang.mutable; 18 19 26 public class MutableLong extends Number implements Comparable , Mutable { 27 28 29 private static final long serialVersionUID = 62986528375L; 30 31 32 private long value; 33 34 37 public MutableLong() { 38 super(); 39 } 40 41 47 public MutableLong(long value) { 48 super(); 49 this.value = value; 50 } 51 52 60 public MutableLong(Number value) { 61 super(); 62 this.value = value.longValue(); 63 } 64 65 71 public Object getValue() { 72 return new Long (this.value); 73 } 74 75 81 public void setValue(long value) { 82 this.value = value; 83 } 84 85 95 public void setValue(Object value) { 96 setValue(((Number ) value).longValue()); 97 } 98 99 106 public int intValue() { 107 return (int) value; 108 } 109 110 115 public long longValue() { 116 return value; 117 } 118 119 124 public float floatValue() { 125 return value; 126 } 127 128 133 public double doubleValue() { 134 return value; 135 } 136 137 147 public boolean equals(Object obj) { 148 if (obj instanceof MutableLong) { 149 return value == ((MutableLong) obj).longValue(); 150 } 151 return false; 152 } 153 154 159 public int hashCode() { 160 return (int) (value ^ (value >>> 32)); 161 } 162 163 171 public int compareTo(Object obj) { 172 MutableLong other = (MutableLong) obj; 173 long anotherVal = other.value; 174 return value < anotherVal ? -1 : (value == anotherVal ? 0 : 1); 175 } 176 177 182 public String toString() { 183 return String.valueOf(value); 184 } 185 186 } 187 | Popular Tags |