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