1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package mnemosyne.core;
17
18
19 /***
20 * An implmentation of the Version interface based on a Java long.
21 * Provides enough capacity for most systems, especially if seeded at
22 * Long.MIN_VALUE.
23 *
24 * This object is immutable.
25 *
26 * @version $Id: LongVersion.java,v 1.1.1.1 2004/08/07 06:41:02 charlesblaxland Exp $
27 */
28 public class LongVersion implements Version
29 {
30 private long value;
31
32 public LongVersion(long value)
33 {
34 this.value = value;
35 }
36
37 public final Version getNext()
38 {
39 return new LongVersion(value + 1);
40 }
41
42 public final int compareTo(Object o)
43 {
44 LongVersion other = (LongVersion) o;
45 if (this.value > other.value)
46 return 1;
47 else if (this.value < other.value)
48 return -1;
49
50 return 0;
51 }
52
53 public final int hashCode()
54 {
55 return (int) value;
56 }
57
58 public final boolean equals(Object obj)
59 {
60 return obj instanceof LongVersion && this.value == ((LongVersion) obj).value;
61 }
62
63 public final String toString()
64 {
65 return Long.toString(value);
66 }
67 }