|
1 | | -/** |
2 | | - * Copyright information and license terms for this software can be |
3 | | - * found in the file LICENSE.TXT included with the distribution. |
4 | | - */ |
5 | | -package org.epics.vtype; |
6 | | - |
7 | | -import java.util.List; |
8 | | -import java.util.Objects; |
9 | | -import static org.epics.vtype.VType.typeOf; |
10 | | - |
11 | | -/** |
12 | | - * Scalar enum with alarm and timestamp. |
13 | | - * Given that enumerated values are of very limited use without |
14 | | - * the labels, and that the current label is the data most likely used, the |
15 | | - * enum is scalar of type {@link String}. The index is provided as an extra field, and |
16 | | - * the list of all possible values is always provided. |
17 | | - * |
18 | | - * @author carcassi |
19 | | - */ |
20 | | -public abstract class VEnum extends Scalar { |
21 | | - |
22 | | - /** |
23 | | - * {@inheritDoc } |
24 | | - */ |
25 | | - @Override |
26 | | - public abstract String getValue(); |
27 | | - |
28 | | - /** |
29 | | - * Return the index of the value in the list of labels. |
30 | | - * |
31 | | - * @return the current index |
32 | | - */ |
33 | | - public abstract int getIndex(); |
34 | | - |
35 | | - /** |
36 | | - * Returns the display information, including all possible choice names. |
37 | | - * |
38 | | - * @return the enum display |
39 | | - */ |
40 | | - public abstract EnumDisplay getDisplay(); |
41 | | - |
42 | | - /** |
43 | | - * Create a new VEnum. |
44 | | - * |
45 | | - * @param index the index in the label array |
46 | | - * @param metaData the metadata |
47 | | - * @param alarm the alarm |
48 | | - * @param time the time |
49 | | - * @return the new value |
50 | | - */ |
51 | | - public static VEnum of(int index, EnumDisplay metaData, Alarm alarm, Time time) { |
52 | | - return new IVEnum(index, metaData, alarm, time); |
53 | | - } |
54 | | - |
55 | | - @Override |
56 | | - public final boolean equals(Object obj) { |
57 | | - if (this == obj) { |
58 | | - return true; |
59 | | - } |
60 | | - |
61 | | - if (obj instanceof VEnum) { |
62 | | - VEnum other = (VEnum) obj; |
63 | | - |
64 | | - return getIndex() == other.getIndex() && |
65 | | - getDisplay().equals(other.getDisplay()) && |
66 | | - getAlarm().equals(other.getAlarm()) && |
67 | | - getTime().equals(other.getTime()); |
68 | | - } |
69 | | - |
70 | | - return false; |
71 | | - } |
72 | | - |
73 | | - @Override |
74 | | - public final int hashCode() { |
75 | | - int hash = 7; |
76 | | - hash = 23 * hash + Objects.hashCode(getValue()); |
77 | | - hash = 23 * hash + Objects.hashCode(getAlarm()); |
78 | | - hash = 23 * hash + Objects.hashCode(getTime()); |
79 | | - return hash; |
80 | | - } |
81 | | - |
82 | | - @Override |
83 | | - public final String toString() { |
84 | | - StringBuilder builder = new StringBuilder(); |
85 | | - Class type = typeOf(this); |
86 | | - builder.append(type.getSimpleName()) |
87 | | - .append("[\"") |
88 | | - .append(getValue()) |
89 | | - .append("\", ") |
90 | | - .append(getAlarm()) |
91 | | - .append(", ") |
92 | | - .append(getTime()) |
93 | | - .append(']'); |
94 | | - return builder.toString(); |
95 | | - } |
96 | | - |
97 | | -} |
| 1 | +/** |
| 2 | + * Copyright information and license terms for this software can be |
| 3 | + * found in the file LICENSE.TXT included with the distribution. |
| 4 | + */ |
| 5 | +package org.epics.vtype; |
| 6 | + |
| 7 | +import java.util.Objects; |
| 8 | + |
| 9 | +/** |
| 10 | + * Scalar enum with alarm and timestamp. |
| 11 | + * Given that enumerated values are of very limited use without |
| 12 | + * the labels, and that the current label is the data most likely used, the |
| 13 | + * enum is scalar of type {@link String}. The index is provided as an extra field, and |
| 14 | + * the list of all possible values is always provided. |
| 15 | + * |
| 16 | + * @author carcassi |
| 17 | + */ |
| 18 | +public abstract class VEnum extends Scalar { |
| 19 | + |
| 20 | + /** |
| 21 | + * {@inheritDoc } |
| 22 | + */ |
| 23 | + @Override |
| 24 | + public abstract String getValue(); |
| 25 | + |
| 26 | + /** |
| 27 | + * Return the index of the value in the list of labels. |
| 28 | + * |
| 29 | + * @return the current index |
| 30 | + */ |
| 31 | + public abstract int getIndex(); |
| 32 | + |
| 33 | + /** |
| 34 | + * Returns the display information, including all possible choice names. |
| 35 | + * |
| 36 | + * @return the enum display |
| 37 | + */ |
| 38 | + public abstract EnumDisplay getDisplay(); |
| 39 | + |
| 40 | + /** |
| 41 | + * Create a new VEnum. |
| 42 | + * |
| 43 | + * @param index the index in the label array |
| 44 | + * @param metaData the metadata |
| 45 | + * @param alarm the alarm |
| 46 | + * @param time the time |
| 47 | + * @return the new value |
| 48 | + */ |
| 49 | + public static VEnum of(int index, EnumDisplay metaData, Alarm alarm, Time time) { |
| 50 | + return new IVEnum(index, metaData, alarm, time); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public final boolean equals(Object obj) { |
| 55 | + if (this == obj) { |
| 56 | + return true; |
| 57 | + } |
| 58 | + |
| 59 | + if (obj instanceof VEnum) { |
| 60 | + VEnum other = (VEnum) obj; |
| 61 | + |
| 62 | + return getIndex() == other.getIndex() && |
| 63 | + getDisplay().equals(other.getDisplay()) && |
| 64 | + getAlarm().equals(other.getAlarm()) && |
| 65 | + getTime().equals(other.getTime()); |
| 66 | + } |
| 67 | + |
| 68 | + return false; |
| 69 | + } |
| 70 | + |
| 71 | + @Override |
| 72 | + public final int hashCode() { |
| 73 | + int hash = 7; |
| 74 | + hash = 23 * hash + Objects.hashCode(getValue()); |
| 75 | + hash = 23 * hash + Objects.hashCode(getAlarm()); |
| 76 | + hash = 23 * hash + Objects.hashCode(getTime()); |
| 77 | + return hash; |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public final String toString() { |
| 82 | + StringBuilder builder = new StringBuilder(); |
| 83 | + Class type = typeOf(this); |
| 84 | + builder.append(type.getSimpleName()) |
| 85 | + .append("[\"") |
| 86 | + .append(getValue()) |
| 87 | + .append("\", ") |
| 88 | + .append(getAlarm()) |
| 89 | + .append(", ") |
| 90 | + .append(getTime()) |
| 91 | + .append(']'); |
| 92 | + return builder.toString(); |
| 93 | + } |
| 94 | + |
| 95 | +} |
0 commit comments