1 | public final class LengthConstraintType implements Serializable {↵ | | 1 | public final class DialShape implements Serializable {↵
|
|
2 | /** For serialization. */↵ | | 2 | /** For serialization. */↵
|
3 | private static final long serialVersionUID = -1156658804028142978L;↵ | | 3 | private static final long serialVersionUID = -3471933055190251131L;↵
|
4 | ↵ | | 4 | ↵
|
5 | /** NONE. */↵ | | 5 | /** Circle. */↵
|
6 | public static final LengthConstraintType NONE ↵ | | 6 | public static final ↵
|
7 | = new LengthConstraintType("LengthConstraintType.NONE");↵ | | 7 | DialShape CIRCLE = new DialShape("DialShape.CIRCLE");↵
|
|
8 | /** Range. */↵ | | 8 | /** Chord. */↵
|
9 | public static final LengthConstraintType RANGE ↵ | | 9 | public static final ↵
|
10 | = new LengthConstraintType("RectangleConstraintType.RANGE");↵ | | 10 | DialShape CHORD = new DialShape("DialShape.CHORD");↵
|
|
11 | /** FIXED. */↵ | | 11 | /** Pie. */↵
|
12 | public static final LengthConstraintType FIXED ↵ | | 12 | public static final ↵
|
13 | = new LengthConstraintType("LengthConstraintType.FIXED");↵ | | 13 | DialShape PIE = new DialShape("DialShape.PIE");↵
|
|
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 LengthConstraintType(String name) {↵ | | 21 | private DialShape(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 true if this object is equal to the specified ↵ | | 33 | * Returns true if this object is equal to the specified ↵
|
34 | * object, and false otherwise.↵ | | 34 | * object, and false otherwise.↵
|
35 | *↵ | | 35 | *↵
|
36 | * @param obj the object (null permitted).↵ | | 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 LengthConstraintType)) {↵ | | 44 | if (!(obj instanceof DialShape)) {↵
|
45 | return false;↵ | | 45 | return false;↵
|
46 | }↵ | | 46 | }↵
|
47 | LengthConstraintType that = (LengthConstraintType) obj;↵ | | 47 | DialShape shape = (DialShape) obj;↵
|
48 | if (!this.name.equals(that.toString())) {↵ | | 48 | if (!this.name.equals(shape.toString())) {↵
|
49 | return false;↵ | | 49 | return false;↵
|
50 | }↵ | | 50 | }↵
|
51 | return true;↵ | | 51 | return true;↵
|
52 | }↵ | | 52 | }↵
|
53 | ↵ | | 53 | ↵
|
54 | /**↵ | | 54 | /**↵
|
55 | * Returns a hash code value for the object.↵ | | 55 | * Returns a hash code for this instance.↵
|
56 | *↵ | | 56 | * ↵
|
57 | * @return The hashcode↵ | | 57 | * @return A hash code.↵
|
58 | */↵ | | 58 | */↵
|
59 | public int hashCode() {↵ | | 59 | public int hashCode() {↵
|
60 | return this.name.hashCode();↵ | | 60 | return this.name.hashCode();↵
|
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(LengthConstraintType.NONE)) {↵ | | 71 | if (this.equals(DialShape.CIRCLE)) {↵
|
71 | return LengthConstraintType.NONE;↵ | | 72 | return DialShape.CIRCLE;↵
|
72 | }↵ | | 73 | }↵
|
73 | else if (this.equals(LengthConstraintType.RANGE)) {↵ | | 74 | else if (this.equals(↵
|
74 | return LengthConstraintType.RANGE↵ | | 75 | DialShape.CHORD)) {↵
|
75 | ;↵ | | 76 | return DialShape.CHORD;↵
|
76 | }↵ | | 77 | } ↵
|
77 | else if (this.equals(LengthConstraintType.FIXED)) {↵ | | 78 | else if (this.equals(DialShape.PIE)) {↵
|
78 | return LengthConstraintType.FIXED;↵ | | 79 | return DialShape.PIE;↵
|
79 | }↵ | | 80 | } ↵
|
80 | return null;↵ | | 81 | return null;↵
|
81 | | | 82 |
|