|
23 | 23 | import java.io.IOException;
|
24 | 24 | import java.io.Serializable;
|
25 | 25 | import java.util.ArrayList;
|
| 26 | +import java.util.Arrays; |
26 | 27 | import java.util.Base64;
|
27 | 28 | import java.util.List;
|
28 | 29 | import java.util.Map;
|
29 | 30 | import java.util.NavigableSet;
|
| 31 | +import java.util.Objects; |
30 | 32 | import javax.xml.bind.annotation.XmlAttribute;
|
31 | 33 | import javax.xml.bind.annotation.XmlElement;
|
32 | 34 | import javax.xml.bind.annotation.XmlRootElement;
|
@@ -201,6 +203,79 @@ public ByteArrayComparable build() {
|
201 | 203 |
|
202 | 204 | }
|
203 | 205 |
|
| 206 | + /** |
| 207 | + * This DTO omits the pseudo-getters in MultiRowRangeFilter.RowRange which break Jackson |
| 208 | + * deserialization. It also avoids adding those as dummy JSON elements. |
| 209 | + */ |
| 210 | + static class RowRangeModel { |
| 211 | + |
| 212 | + protected byte[] startRow; |
| 213 | + |
| 214 | + protected boolean startRowInclusive = true; |
| 215 | + |
| 216 | + protected byte[] stopRow; |
| 217 | + |
| 218 | + protected boolean stopRowInclusive = false; |
| 219 | + |
| 220 | + public RowRangeModel() { |
| 221 | + } |
| 222 | + |
| 223 | + public RowRangeModel(MultiRowRangeFilter.RowRange rr) { |
| 224 | + this.startRow = rr.getStartRow(); |
| 225 | + this.startRowInclusive = rr.isStartRowInclusive(); |
| 226 | + this.stopRow = rr.getStopRow(); |
| 227 | + this.stopRowInclusive = rr.isStopRowInclusive(); |
| 228 | + } |
| 229 | + |
| 230 | + public MultiRowRangeFilter.RowRange build() { |
| 231 | + return new MultiRowRangeFilter.RowRange(startRow, startRowInclusive, stopRow, |
| 232 | + stopRowInclusive); |
| 233 | + } |
| 234 | + |
| 235 | + public byte[] getStartRow() { |
| 236 | + return startRow; |
| 237 | + } |
| 238 | + |
| 239 | + public byte[] getStopRow() { |
| 240 | + return stopRow; |
| 241 | + } |
| 242 | + |
| 243 | + /** Returns if start row is inclusive. */ |
| 244 | + public boolean isStartRowInclusive() { |
| 245 | + return startRowInclusive; |
| 246 | + } |
| 247 | + |
| 248 | + /** Returns if stop row is inclusive. */ |
| 249 | + public boolean isStopRowInclusive() { |
| 250 | + return stopRowInclusive; |
| 251 | + } |
| 252 | + |
| 253 | + @Override |
| 254 | + public int hashCode() { |
| 255 | + final int prime = 31; |
| 256 | + int result = 1; |
| 257 | + result = prime * result + Arrays.hashCode(startRow); |
| 258 | + result = prime * result + Arrays.hashCode(stopRow); |
| 259 | + result = prime * result + Objects.hash(startRowInclusive, stopRowInclusive); |
| 260 | + return result; |
| 261 | + } |
| 262 | + |
| 263 | + @Override |
| 264 | + public boolean equals(Object obj) { |
| 265 | + if (this == obj) { |
| 266 | + return true; |
| 267 | + } |
| 268 | + if (!(obj instanceof RowRangeModel)) { |
| 269 | + return false; |
| 270 | + } |
| 271 | + RowRangeModel other = (RowRangeModel) obj; |
| 272 | + return Arrays.equals(startRow, other.startRow) |
| 273 | + && startRowInclusive == other.startRowInclusive && Arrays.equals(stopRow, other.stopRow) |
| 274 | + && stopRowInclusive == other.stopRowInclusive; |
| 275 | + } |
| 276 | + |
| 277 | + } |
| 278 | + |
204 | 279 | // A grab bag of fields, would have been a union if this were C.
|
205 | 280 | // These are null by default and will only be serialized if set (non null).
|
206 | 281 | @XmlAttribute
|
@@ -240,7 +315,7 @@ public ByteArrayComparable build() {
|
240 | 315 | @XmlElement
|
241 | 316 | public List<String> prefixes;
|
242 | 317 | @XmlElement
|
243 |
| - private List<RowRange> ranges; |
| 318 | + private List<RowRangeModel> ranges; |
244 | 319 | @XmlElement
|
245 | 320 | public List<Long> timestamps;
|
246 | 321 |
|
@@ -331,8 +406,7 @@ public FilterModel(Filter filter) {
|
331 | 406 | case MultiRowRangeFilter:
|
332 | 407 | this.ranges = new ArrayList<>();
|
333 | 408 | for (RowRange range : ((MultiRowRangeFilter) filter).getRowRanges()) {
|
334 |
| - this.ranges.add(new RowRange(range.getStartRow(), range.isStartRowInclusive(), |
335 |
| - range.getStopRow(), range.isStopRowInclusive())); |
| 409 | + this.ranges.add(new RowRangeModel(range)); |
336 | 410 | }
|
337 | 411 | break;
|
338 | 412 | case PageFilter:
|
@@ -436,7 +510,11 @@ public Filter build() {
|
436 | 510 | }
|
437 | 511 | break;
|
438 | 512 | case MultiRowRangeFilter: {
|
439 |
| - filter = new MultiRowRangeFilter(ranges); |
| 513 | + ArrayList<MultiRowRangeFilter.RowRange> rowRanges = new ArrayList<>(ranges.size()); |
| 514 | + for (RowRangeModel rangeModel : ranges) { |
| 515 | + rowRanges.add(rangeModel.build()); |
| 516 | + } |
| 517 | + filter = new MultiRowRangeFilter(rowRanges); |
440 | 518 | }
|
441 | 519 | break;
|
442 | 520 | case PageFilter:
|
|
0 commit comments