1 | public final class CategoryAnchor implements Serializable {↵ | | 1 | public final class RangeType implements Serializable {↵
|
|
2 | /** For serialization. */↵ | | 2 | /** For serialization. */↵
|
3 | private static final long serialVersionUID = -2604142742210173810L;↵ | | 3 | private static final long serialVersionUID = -9073319010650549239L;↵
|
4 | ↵ | | 4 | ↵
|
5 | /** Start of period. */↵ | | 5 | /** ↵
|
6 | public static final CategoryAnchor START ↵ | | |
|
7 | = new CategoryAnchor("CategoryAnchor.START");↵ | | |
|
|
8 | /** Middle of period↵ | | 6 | Full range (positive and negative). */↵
|
| | | 7 | public static final RangeType FULL = new RangeType("RangeType.FULL");↵
|
|
9 | . */↵ | | 8 | /** Positive range. */↵
|
10 | public static final CategoryAnchor MIDDLE ↵ | | 9 | public static final RangeType POSITIVE ↵
|
11 | = new CategoryAnchor("CategoryAnchor.MIDDLE");↵ | | 10 | = new RangeType("RangeType.POSITIVE");↵
|
|
12 | /** End of period. */↵ | | 11 | /** Negative range. */↵
|
13 | public static final CategoryAnchor END ↵ | | 12 | public static final RangeType NEGATIVE ↵
|
14 | = new CategoryAnchor("CategoryAnchor.END");↵ | | 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 CategoryAnchor(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 other object.↵ | | 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 CategoryAnchor)) {↵ | | 44 | if (!(obj instanceof RangeType)) {↵
|
46 | return false;↵ | | 45 | return false;↵
|
47 | }↵ | | 46 | }↵
|
48 | CategoryAnchor position = (CategoryAnchor) obj;↵ | | 47 | RangeType that = (RangeType) obj;↵
|
49 | if (!this.name.equals(position.toString())) {↵ | | 48 | if (!this.name.equals(that.toString())) {↵
|
50 | return false;↵ | | 49 | return false;↵
|
51 | }↵ | | 50 | }↵
|
52 | return true;↵ | | 51 | return true;↵
|
| | | 52 | }↵
|
53 | }↵ | | 53 | ↵
|
54 | ↵ | | 54 | /**↵
|
| | | 55 | * Returns a hash code value for the object.↵
|
| | | 56 | *↵
|
| | | 57 | * @return The hashcode↵
|
| | | 58 | */↵
|
| | | 59 | public int hashCode() {↵
|
| | | 60 | return this.name.hashCode();↵
|
| | | 61 | }↵
|
|
55 | /**↵ | | 62 | /**↵
|
56 | * Ensures that serialization returns the unique instances.↵ | | 63 | * Ensures that serialization returns the unique instances.↵
|
57 | * ↵ | | 64 | * ↵
|
58 | * @return The object.↵ | | 65 | * @return The object.↵
|
59 | * ↵ | | 66 | * ↵
|
60 | * @throws ObjectStreamException if there is a problem.↵ | | 67 | * @throws ObjectStreamException if there is a problem.↵
|
61 | */↵ | | 68 | */↵
|
62 | private Object readResolve() throws ObjectStreamException {↵ | | 69 | private Object readResolve() throws ObjectStreamException {↵
|
63 | if (this.equals(CategoryAnchor.START)) {↵ | | 70 | if (this.equals(RangeType.FULL)) {↵
|
64 | return CategoryAnchor.START;↵ | | 71 | return RangeType.FULL;↵
|
65 | }↵ | | 72 | }↵
|
66 | else if (this.equals(CategoryAnchor.MIDDLE)) {↵ | | 73 | else if (this.equals(RangeType.POSITIVE)) {↵
|
67 | return CategoryAnchor.MIDDLE;↵ | | 74 | return RangeType.POSITIVE;↵
|
68 | } ↵ | | 75 | }↵
|
69 | else if (this.equals(CategoryAnchor.END)) {↵ | | 76 | else if (this.equals(RangeType.NEGATIVE)) {↵
|
70 | return CategoryAnchor.END;↵ | | 77 | return RangeType.NEGATIVE;↵
|
71 | } ↵ | | 78 | }↵
|
72 | return null | | 79 | return null
|