1 | public final class RangeType implements Serializable {↵ | | 1 | public final class TimePeriodAnchor implements Serializable {↵
|
|
2 | /** For serialization. */↵ | | 2 | /** For serialization. */↵
|
3 | private static final long serialVersionUID = -9073319010650549239L;↵ | | 3 | private static final long serialVersionUID = 2011955697457548862L;↵
|
4 | ↵ | | 4 | ↵
|
5 | /** Full range (positive and negative). */↵ | | 5 | /** ↵
|
6 | public static final RangeType FULL = new RangeType("RangeType.FULL");↵ | | |
|
|
7 | /** Positive range↵ | | 6 | Start of period. */↵
|
| | | 7 | public static final TimePeriodAnchor START ↵
|
| | | 8 | = new TimePeriodAnchor("TimePeriodAnchor.START");↵
|
|
8 | . */↵ | | 9 | /** Middle of period. */↵
|
9 | public static final RangeType POSITIVE ↵ | | 10 | public static final ↵
|
10 | = new RangeType("RangeType.POSITIV↵ | | 11 | TimePeriodAnchor MIDDLE ↵
|
11 | E");↵ | | 12 | = new TimePeriodAnchor("TimePeriodAnchor.MIDDLE");↵
|
|
12 | /** Negative range. */↵ | | 13 | /** End of period. */↵
|
13 | public static final RangeType NEGATIVE ↵ | | 14 | public static final ↵
|
14 | = new RangeType("RangeType.NEGATIVE↵ | | 15 | TimePeriodAnchor END ↵
|
15 | ");↵ | | 16 | = new TimePeriodAnchor("TimePeriodAnchor.END");↵
|
|
16 | /** The name. */↵ | | 17 | /** The name. */↵
|
17 | private String name;↵ | | 18 | private String name;↵
|
|
18 | /**↵ | | 19 | /**↵
|
19 | * Private constructor.↵ | | 20 | * Private constructor.↵
|
20 | *↵ | | 21 | *↵
|
21 | * @param name the name.↵ | | 22 | * @param name the name.↵
|
22 | */↵ | | 23 | */↵
|
23 | private RangeType(String name) {↵ | | 24 | private TimePeriodAnchor(String name) {↵
|
24 | this.name = name;↵ | | 25 | this.name = name;↵
|
25 | }↵ | | 26 | }↵
|
|
26 | /**↵ | | 27 | /**↵
|
27 | * Returns a string representing the object.↵ | | 28 | * Returns a string representing the object.↵
|
28 | *↵ | | 29 | *↵
|
29 | * @return The string.↵ | | 30 | * @return The string.↵
|
30 | */↵ | | 31 | */↵
|
31 | public String toString() {↵ | | 32 | public String toString() {↵
|
32 | return this.name;↵ | | 33 | return this.name;↵
|
33 | }↵ | | 34 | }↵
|
|
34 | /**↵ | | 35 | /**↵
|
35 | * Returns <code>true</code> if this object is equal to the specified ↵ | | 36 | * Returns <code>true</code> if this object is equal to the specified ↵
|
36 | * object, and <code>false</code> otherwise.↵ | | 37 | * object, and <code>false</code> otherwise.↵
|
37 | *↵ | | 38 | *↵
|
38 | * @param obj the other object.↵ | | 39 | * @param obj the other object.↵
|
39 | *↵ | | 40 | *↵
|
40 | * @return A boolean.↵ | | 41 | * @return A boolean.↵
|
41 | */↵ | | 42 | */↵
|
42 | public boolean equals(Object obj) {↵ | | 43 | public boolean equals(Object obj) {↵
|
|
43 | if (this == obj) {↵ | | 44 | if (this == obj) {↵
|
44 | return true;↵ | | 45 | return true;↵
|
45 | }↵ | | 46 | }↵
|
46 | if (!(obj instanceof RangeType)) {↵ | | 47 | if (!(obj instanceof TimePeriodAnchor)) {↵
|
47 | return false;↵ | | 48 | return false;↵
|
48 | }↵ | | 49 | }↵
|
|
49 | RangeType that = (RangeType) obj;↵ | | 50 | TimePeriodAnchor position = (TimePeriodAnchor) obj;↵
|
50 | if (!this.name.equals(that.toString())) {↵ | | 51 | if (!this.name.equals(position.name)) {↵
|
51 | return false;↵ | | 52 | return false;↵
|
52 | }↵ | | 53 | }↵
|
|
53 | return true;↵ | | 54 | return true;↵
|
54 | }↵ | | 55 | }↵
|
55 | ↵ | | |
|
56 | /**↵ | | 56 | /**↵
|
57 | * Returns a hash code value for the object.↵ | | 57 | * Returns a hash code value for the object.↵
|
58 | *↵ | | 58 | *↵
|
59 | * @return The hashcode↵ | | 59 | * @return The hashcode↵
|
60 | */↵ | | 60 | */↵
|
61 | public int hashCode() {↵ | | 61 | public int hashCode() {↵
|
62 | return this.name.hashCode();↵ | | 62 | return this.name.hashCode();↵
|
63 | }↵ | | 63 | }↵
|
| | | 64 | ↵
|
64 | /**↵ | | 65 | /**↵
|
65 | * Ensures that serialization returns the unique instances.↵ | | 66 | * Ensures that serialization returns the unique instances.↵
|
66 | * ↵ | | 67 | * ↵
|
67 | * @return The object.↵ | | 68 | * @return The object.↵
|
68 | * ↵ | | 69 | * ↵
|
69 | * @throws ObjectStreamException if there is a problem.↵ | | 70 | * @throws ObjectStreamException if there is a problem.↵
|
70 | */↵ | | 71 | */↵
|
71 | private Object readResolve() throws ObjectStreamException {↵ | | 72 | private Object readResolve() throws ObjectStreamException {↵
|
72 | if (this.equals(RangeType.FULL)) {↵ | | 73 | if (this.equals(TimePeriodAnchor.START)) {↵
|
73 | return RangeType.FULL;↵ | | 74 | return TimePeriodAnchor.START;↵
|
74 | }↵ | | 75 | }↵
|
75 | else if (this.equals(RangeType.POSITIVE)) {↵ | | 76 | else if (this.equals(TimePeriodAnchor.MIDDLE)) {↵
|
76 | return RangeType.POSITIVE;↵ | | 77 | return TimePeriodAnchor.MIDDLE;↵
|
77 | }↵ | | 78 | }↵
|
78 | else if (this.equals(RangeType.NEGATIVE)) {↵ | | 79 | else if (this.equals(TimePeriodAnchor.END)) {↵
|
79 | return RangeType.NEGATIVE;↵ | | 80 | return TimePeriodAnchor.END;↵
|
80 | }↵ | | 81 | }↵
|
81 | return null | | 82 | return null
|