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