|
27 | 27 | public interface Value { |
28 | 28 | /** |
29 | 29 | * Returns type of this value. |
30 | | - * |
| 30 | + * <p/> |
31 | 31 | * Note that you can't use <code>instanceof</code> to check type of a value because type of a mutable value is variable. |
32 | 32 | */ |
33 | 33 | public ValueType getValueType(); |
34 | 34 |
|
35 | 35 | /** |
36 | 36 | * Returns immutable copy of this value. |
37 | | - * |
| 37 | + * <p/> |
38 | 38 | * This method simply returns <code>this</code> without copying the value if this value is already immutable. |
39 | 39 | */ |
40 | | - public ImmutableValue immutableValue(); |
| 40 | + ImmutableValue toImmutable(); |
41 | 41 |
|
42 | 42 | /** |
43 | 43 | * Returns true if type of this value is Nil. |
44 | | - * |
| 44 | + * <p/> |
45 | 45 | * If this method returns true, {@code asNilValue} never throws exceptions. |
46 | 46 | * Note that you can't use <code>instanceof</code> or cast <code>((NilValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
47 | 47 | */ |
48 | | - public boolean isNilValue(); |
| 48 | + boolean isNilValue(); |
49 | 49 |
|
50 | 50 | /** |
51 | 51 | * Returns true if type of this value is Boolean. |
52 | | - * |
| 52 | + * <p/> |
53 | 53 | * If this method returns true, {@code asBooleanValue} never throws exceptions. |
54 | 54 | * Note that you can't use <code>instanceof</code> or cast <code>((BooleanValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
55 | 55 | */ |
56 | | - public boolean isBooleanValue(); |
| 56 | + boolean isBooleanValue(); |
57 | 57 |
|
58 | 58 | /** |
59 | 59 | * Returns true if type of this value is Integer or Float. |
60 | | - * |
| 60 | + * <p/> |
61 | 61 | * If this method returns true, {@code asNumberValue} never throws exceptions. |
62 | 62 | * Note that you can't use <code>instanceof</code> or cast <code>((NumberValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
63 | 63 | */ |
64 | | - public boolean isNumberValue(); |
| 64 | + boolean isNumberValue(); |
65 | 65 |
|
66 | 66 | /** |
67 | 67 | * Returns true if type of this value is Integer. |
68 | | - * |
| 68 | + * <p/> |
69 | 69 | * If this method returns true, {@code asIntegerValue} never throws exceptions. |
70 | 70 | * Note that you can't use <code>instanceof</code> or cast <code>((IntegerValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
71 | 71 | */ |
72 | | - public boolean isIntegerValue(); |
| 72 | + boolean isIntegerValue(); |
73 | 73 |
|
74 | 74 | /** |
75 | 75 | * Returns true if type of this value is Float. |
76 | | - * |
| 76 | + * <p/> |
77 | 77 | * If this method returns true, {@code asFloatValue} never throws exceptions. |
78 | 78 | * Note that you can't use <code>instanceof</code> or cast <code>((FloatValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
79 | 79 | */ |
80 | | - public boolean isFloatValue(); |
| 80 | + boolean isFloatValue(); |
81 | 81 |
|
82 | 82 | /** |
83 | 83 | * Returns true if type of this value is String or Binary. |
84 | | - * |
| 84 | + * <p/> |
85 | 85 | * If this method returns true, {@code asRawValue} never throws exceptions. |
86 | 86 | * Note that you can't use <code>instanceof</code> or cast <code>((RawValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
87 | 87 | */ |
88 | | - public boolean isRawValue(); |
| 88 | + boolean isRawValue(); |
89 | 89 |
|
90 | 90 | /** |
91 | 91 | * Returns true if type of this value is Binary. |
92 | | - * |
| 92 | + * <p/> |
93 | 93 | * If this method returns true, {@code asBinaryValue} never throws exceptions. |
94 | 94 | * Note that you can't use <code>instanceof</code> or cast <code>((BinaryValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
95 | 95 | */ |
96 | | - public boolean isBinaryValue(); |
| 96 | + boolean isBinaryValue(); |
97 | 97 |
|
98 | 98 | /** |
99 | 99 | * Returns true if type of this value is String. |
100 | | - * |
| 100 | + * <p/> |
101 | 101 | * If this method returns true, {@code asStringValue} never throws exceptions. |
102 | 102 | * Note that you can't use <code>instanceof</code> or cast <code>((StringValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
103 | 103 | */ |
104 | | - public boolean isStringValue(); |
| 104 | + boolean isStringValue(); |
105 | 105 |
|
106 | 106 | /** |
107 | 107 | * Returns true if type of this value is Array. |
108 | | - * |
| 108 | + * <p/> |
109 | 109 | * If this method returns true, {@code asArrayValue} never throws exceptions. |
110 | 110 | * Note that you can't use <code>instanceof</code> or cast <code>((ArrayValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
111 | 111 | */ |
112 | | - public boolean isArrayValue(); |
| 112 | + boolean isArrayValue(); |
113 | 113 |
|
114 | 114 | /** |
115 | 115 | * Returns true if type of this value is Map. |
116 | | - * |
| 116 | + * <p/> |
117 | 117 | * If this method returns true, {@code asMapValue} never throws exceptions. |
118 | 118 | * Note that you can't use <code>instanceof</code> or cast <code>((MapValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
119 | 119 | */ |
120 | | - public boolean isMapValue(); |
| 120 | + boolean isMapValue(); |
121 | 121 |
|
122 | 122 | /** |
123 | 123 | * Returns true if type of this an Extension. |
124 | | - * |
| 124 | + * <p/> |
125 | 125 | * If this method returns true, {@code asExtensionValue} never throws exceptions. |
126 | 126 | * Note that you can't use <code>instanceof</code> or cast <code>((ExtensionValue) thisValue)</code> to check type of a value because |
127 | 127 | * type of a mutable value is variable. |
128 | 128 | */ |
129 | | - public boolean isExtensionValue(); |
| 129 | + boolean isExtensionValue(); |
130 | 130 |
|
131 | 131 | /** |
132 | 132 | * Returns the value as {@code NilValue}. Otherwise throws {@code MessageTypeCastException}. |
133 | | - * |
| 133 | + * <p/> |
134 | 134 | * Note that you can't use <code>instanceof</code> or cast <code>((NilValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
135 | 135 | * |
136 | | - * @throws MessageTypeCastException |
137 | | - * If type of this value is not Nil. |
| 136 | + * @throws MessageTypeCastException If type of this value is not Nil. |
138 | 137 | */ |
139 | | - public NilValue asNilValue(); |
| 138 | + NilValue asNilValue(); |
140 | 139 |
|
141 | 140 | /** |
142 | 141 | * Returns the value as {@code BooleanValue}. Otherwise throws {@code MessageTypeCastException}. |
143 | | - * |
| 142 | + * <p/> |
144 | 143 | * Note that you can't use <code>instanceof</code> or cast <code>((BooleanValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
145 | 144 | * |
146 | | - * @throws MessageTypeCastException |
147 | | - * If type of this value is not Boolean. |
| 145 | + * @throws MessageTypeCastException If type of this value is not Boolean. |
148 | 146 | */ |
149 | | - public BooleanValue asBooleanValue(); |
| 147 | + BooleanValue asBooleanValue(); |
150 | 148 |
|
151 | 149 | /** |
152 | 150 | * Returns the value as {@code NumberValue}. Otherwise throws {@code MessageTypeCastException}. |
153 | | - * |
| 151 | + * <p/> |
154 | 152 | * Note that you can't use <code>instanceof</code> or cast <code>((NumberValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
155 | 153 | * |
156 | | - * @throws MessageTypeCastException |
157 | | - * If type of this value is not Integer or Float. |
| 154 | + * @throws MessageTypeCastException If type of this value is not Integer or Float. |
158 | 155 | */ |
159 | | - public NumberValue asNumberValue(); |
| 156 | + NumberValue asNumberValue(); |
160 | 157 |
|
161 | 158 | /** |
162 | 159 | * Returns the value as {@code IntegerValue}. Otherwise throws {@code MessageTypeCastException}. |
163 | | - * |
| 160 | + * <p/> |
164 | 161 | * Note that you can't use <code>instanceof</code> or cast <code>((IntegerValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
165 | 162 | * |
166 | | - * @throws MessageTypeCastException |
167 | | - * If type of this value is not Integer. |
| 163 | + * @throws MessageTypeCastException If type of this value is not Integer. |
168 | 164 | */ |
169 | | - public IntegerValue asIntegerValue(); |
| 165 | + IntegerValue asIntegerValue(); |
170 | 166 |
|
171 | 167 | /** |
172 | 168 | * Returns the value as {@code FloatValue}. Otherwise throws {@code MessageTypeCastException}. |
173 | | - * |
| 169 | + * <p/> |
174 | 170 | * Note that you can't use <code>instanceof</code> or cast <code>((FloatValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
175 | 171 | * |
176 | | - * @throws MessageTypeCastException |
177 | | - * If type of this value is not Float. |
| 172 | + * @throws MessageTypeCastException If type of this value is not Float. |
178 | 173 | */ |
179 | | - public FloatValue asFloatValue(); |
| 174 | + FloatValue asFloatValue(); |
180 | 175 |
|
181 | 176 | /** |
182 | 177 | * Returns the value as {@code RawValue}. Otherwise throws {@code MessageTypeCastException}. |
183 | | - * |
| 178 | + * <p/> |
184 | 179 | * Note that you can't use <code>instanceof</code> or cast <code>((RawValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
185 | 180 | * |
186 | | - * @throws MessageTypeCastException |
187 | | - * If type of this value is not Binary or String. |
| 181 | + * @throws MessageTypeCastException If type of this value is not Binary or String. |
188 | 182 | */ |
189 | | - public RawValue asRawValue(); |
| 183 | + RawValue asRawValue(); |
190 | 184 |
|
191 | 185 | /** |
192 | 186 | * Returns the value as {@code BinaryValue}. Otherwise throws {@code MessageTypeCastException}. |
193 | | - * |
| 187 | + * <p/> |
194 | 188 | * Note that you can't use <code>instanceof</code> or cast <code>((BinaryValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
195 | 189 | * |
196 | | - * @throws MessageTypeCastException |
197 | | - * If type of this value is not Binary. |
| 190 | + * @throws MessageTypeCastException If type of this value is not Binary. |
198 | 191 | */ |
199 | | - public BinaryValue asBinaryValue(); |
| 192 | + BinaryValue asBinaryValue(); |
200 | 193 |
|
201 | 194 | /** |
202 | 195 | * Returns the value as {@code StringValue}. Otherwise throws {@code MessageTypeCastException}. |
203 | | - * |
| 196 | + * <p/> |
204 | 197 | * Note that you can't use <code>instanceof</code> or cast <code>((StringValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
205 | 198 | * |
206 | | - * @throws MessageTypeCastException |
207 | | - * If type of this value is not String. |
| 199 | + * @throws MessageTypeCastException If type of this value is not String. |
208 | 200 | */ |
209 | | - public StringValue asStringValue(); |
| 201 | + StringValue asStringValue(); |
210 | 202 |
|
211 | 203 | /** |
212 | 204 | * Returns the value as {@code ArrayValue}. Otherwise throws {@code MessageTypeCastException}. |
213 | | - * |
| 205 | + * <p/> |
214 | 206 | * Note that you can't use <code>instanceof</code> or cast <code>((ArrayValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
215 | 207 | * |
216 | | - * @throws MessageTypeCastException |
217 | | - * If type of this value is not Array. |
| 208 | + * @throws MessageTypeCastException If type of this value is not Array. |
218 | 209 | */ |
219 | | - public ArrayValue asArrayValue(); |
| 210 | + ArrayValue asArrayValue(); |
220 | 211 |
|
221 | 212 | /** |
222 | 213 | * Returns the value as {@code MapValue}. Otherwise throws {@code MessageTypeCastException}. |
223 | | - * |
| 214 | + * <p/> |
224 | 215 | * Note that you can't use <code>instanceof</code> or cast <code>((MapValue) thisValue)</code> to check type of a value because type of a mutable value is variable. |
225 | 216 | * |
226 | | - * @throws MessageTypeCastException |
227 | | - * If type of this value is not Map. |
| 217 | + * @throws MessageTypeCastException If type of this value is not Map. |
228 | 218 | */ |
229 | | - public MapValue asMapValue(); |
| 219 | + MapValue asMapValue(); |
230 | 220 |
|
231 | 221 | /** |
232 | 222 | * Returns the value as {@code ExtensionValue}. Otherwise throws {@code MessageTypeCastException}. |
233 | | - * |
| 223 | + * <p/> |
234 | 224 | * Note that you can't use <code>instanceof</code> or cast <code>((ExtensionValue) thisValue)</code> to check type of a value |
235 | 225 | * because type of a mutable value is variable. |
236 | 226 | * |
237 | | - * @throws MessageTypeCastException |
238 | | - * If type of this value is not an Extension. |
| 227 | + * @throws MessageTypeCastException If type of this value is not an Extension. |
239 | 228 | */ |
240 | | - public ExtensionValue asExtensionValue(); |
| 229 | + ExtensionValue asExtensionValue(); |
241 | 230 |
|
242 | 231 | /** |
243 | 232 | * Serializes the value using the specified {@code MessagePacker} |
244 | 233 | * |
245 | | - * @see MessagePacker |
| 234 | + * @see MessagePacker |
246 | 235 | */ |
247 | | - public void writeTo(MessagePacker pk) throws IOException; |
| 236 | + void writeTo(MessagePacker pk) throws IOException; |
| 237 | + |
| 238 | + |
| 239 | + /** |
| 240 | + * Accept a visitor to traverse this value |
| 241 | + * @param visitor |
| 242 | + */ |
| 243 | + void accept(ValueVisitor visitor); |
248 | 244 |
|
249 | 245 | /** |
250 | 246 | * Compares this value to the specified object. |
251 | | - * |
| 247 | + * <p/> |
252 | 248 | * This method returns {@code true} if type and value are equivalent. |
253 | 249 | * If this value is {@code MapValue} or {@code ArrayValue}, this method check equivalence of elements recursively. |
254 | 250 | */ |
255 | | - public boolean equals(Object obj); |
| 251 | + boolean equals(Object obj); |
256 | 252 | } |
0 commit comments