1 | public final class LengthConstraintType implements Serializable {↵ | | 1 | public final class RangeType implements Serializable {↵
|
|
2 | /** For serialization. */↵ | | 2 | /** For serialization. */↵
|
3 | private static final long serialVersionUID = -1156658804028142978L;↵ | | 3 | private static final long serialVersionUID = -9073319010650549239L;↵
|
4 | ↵ | | 4 | ↵
|
5 | /** NONE. */↵ | | 5 | /** ↵
|
6 | public static final LengthConstraintType NONE ↵ | | |
|
7 | = new LengthConstraintType("LengthConstraint↵ | | 6 | Full range (positive and negative). */↵
|
8 | Type.NONE");↵ | | 7 | public static final RangeType FULL = new RangeType("RangeType.FULL");↵
|
|
9 | /** Range. */↵ | | 8 | /** Positive range. */↵
|
10 | public static final LengthConstraintType RANGE ↵ | | 9 | public static final RangeType POSITIVE ↵
|
11 | = new LengthConstraintType("RectangleConstraintType.RANGE");↵ | | 10 | = new RangeType("RangeType.POSITIVE");↵
|
|
12 | /** FIXED. */↵ | | 11 | /** Negative range. */↵
|
13 | public static final LengthConstraintType FIXED ↵ | | 12 | public static final RangeType NEGATIVE ↵
|
14 | = new LengthConstraintType("LengthConstraintType.FIXED");↵ | | 13 | = new RangeType("RangeType.NEGATIVE");↵
|
|
15 | /** The name. */↵ | | 14 | /** The name. */↵
|
16 | private String name;↵ | | 15 | private String name;↵
|
|
17 | /**↵ | | 16 | /**↵
|
18 | * Private constructor.↵ | | 17 | * Private constructor.↵
|
19 | *↵ | | 18 | *↵
|
20 | * @param name the name.↵ | | 19 | * @param name the name.↵
|
21 | */↵ | | 20 | */↵
|
22 | private LengthConstraintType(String name) {↵ | | 21 | private RangeType(String name) {↵
|
23 | this.name = name;↵ | | 22 | this.name = name;↵
|
24 | }↵ | | 23 | }↵
|
|
25 | /**↵ | | 24 | /**↵
|
26 | * Returns a string representing the object.↵ | | 25 | * Returns a string representing the object.↵
|
27 | *↵ | | 26 | *↵
|
28 | * @return The string.↵ | | 27 | * @return The string.↵
|
29 | */↵ | | 28 | */↵
|
30 | public String toString() {↵ | | 29 | public String toString() {↵
|
31 | return this.name;↵ | | 30 | return this.name;↵
|
32 | }↵ | | 31 | }↵
|
|
33 | /**↵ | | 32 | /**↵
|
34 | * 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 ↵
|
35 | * object, and <code>false</code> otherwise.↵ | | 34 | * object, and <code>false</code> otherwise.↵
|
36 | *↵ | | 35 | *↵
|
37 | * @param obj the object (<code>null</code> permitted).↵ | | 36 | * @param obj the other object.↵
|
38 | *↵ | | 37 | *↵
|
39 | * @return A boolean.↵ | | 38 | * @return A boolean.↵
|
40 | */↵ | | 39 | */↵
|
41 | public boolean equals(Object obj) {↵ | | 40 | public boolean equals(Object obj) {↵
|
|
42 | if (this == obj) {↵ | | 41 | if (this == obj) {↵
|
43 | return true;↵ | | 42 | return true;↵
|
44 | }↵ | | 43 | }↵
|
45 | if (!(obj instanceof LengthConstraintType)) {↵ | | 44 | if (!(obj instanceof RangeType)) {↵
|
46 | return false;↵ | | 45 | return false;↵
|
47 | }↵ | | 46 | }↵
|
48 | LengthConstraintType that = (LengthConstraintType) obj;↵ | | 47 | RangeType that = (RangeType) obj;↵
|
49 | if (!this.name.equals(that.toString())) {↵ | | 48 | if (!this.name.equals(that.toString())) {↵
|
50 | return false;↵ | | 49 | return false;↵
|
51 | }↵ | | 50 | }↵
|
52 | return true;↵ | | 51 | return true;↵
|
53 | }↵ | | 52 | }↵
|
54 | ↵ | | 53 | ↵
|
55 | /**↵ | | 54 | /**↵
|
56 | * Returns a hash code value for the object.↵ | | 55 | * Returns a hash code value for the object.↵
|
57 | *↵ | | 56 | *↵
|
58 | * @return The hashcode↵ | | 57 | * @return The hashcode↵
|
59 | */↵ | | 58 | */↵
|
60 | public int hashCode() {↵ | | 59 | public int hashCode() {↵
|
61 | return this.name.hashCode();↵ | | 60 | return this.name.hashCode();↵
|
62 | }↵ | | 61 | }↵
|
|
63 | /**↵ | | 62 | /**↵
|
64 | * Ensures that serialization returns the unique instances.↵ | | 63 | * Ensures that serialization returns the unique instances.↵
|
65 | * ↵ | | 64 | * ↵
|
66 | * @return The object.↵ | | 65 | * @return The object.↵
|
67 | * ↵ | | 66 | * ↵
|
68 | * @throws ObjectStreamException if there is a problem.↵ | | 67 | * @throws ObjectStreamException if there is a problem.↵
|
69 | */↵ | | 68 | */↵
|
70 | private Object readResolve() throws ObjectStreamException {↵ | | 69 | private Object readResolve() throws ObjectStreamException {↵
|
71 | if (this.equals(LengthConstraintType.NONE)) {↵ | | 70 | if (this.equals(RangeType.FULL)) {↵
|
72 | return LengthConstraintType.NONE;↵ | | 71 | return RangeType.FULL;↵
|
73 | }↵ | | 72 | }↵
|
74 | else if (this.equals(LengthConstraintType.RANGE)) {↵ | | 73 | else if (this.equals(RangeType.POSITIVE)) {↵
|
75 | return LengthConstraintType.RANGE;↵ | | 74 | return RangeType.POSITIVE;↵
|
76 | }↵ | | 75 | }↵
|
77 | else if (this.equals(LengthConstraintType.FIXED)) {↵ | | 76 | else if (this.equals(↵
|
78 | return LengthConstraintType.FIXED↵ | | 77 | RangeType.NEGATIVE)) {↵
|
79 | ;↵ | | 78 | return RangeType.NEGATIVE;↵
|
80 | }↵ | | 79 | }↵
|
81 | return null | | 80 | return null
|