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