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