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