@Test public void testUnion() { final ByteArrayRange bar1 = new ByteArrayRange(new ByteArray("232").getBytes(), new ByteArray("332").getBytes()); final ByteArrayRange bar2 = new ByteArrayRange(new ByteArray("282").getBytes(), new ByteArray("300").getBytes()); final ByteArrayRange bar3 = new ByteArrayRange(new ByteArray("272").getBytes(), new ByteArray("340").getBytes()); final ByteArrayRange bar4 = new ByteArrayRange(new ByteArray("392").getBytes(), new ByteArray("410").getBytes()); Collection<ByteArrayRange> l1 = new ArrayList<>(Arrays.asList(bar4, bar3, bar1, bar2)); l1 = ByteArrayRange.mergeIntersections(l1, MergeOperation.UNION); Collection<ByteArrayRange> l2 = new ArrayList<>(Arrays.asList(bar1, bar4, bar2, bar3)); l2 = ByteArrayRange.mergeIntersections(l2, MergeOperation.UNION); assertEquals(2, l1.size()); assertEquals(l1, l2); assertEquals( new ByteArrayRange(new ByteArray("232").getBytes(), new ByteArray("340").getBytes()), ((ArrayList<ByteArrayRange>) l1).get(0)); assertEquals( new ByteArrayRange(new ByteArray("392").getBytes(), new ByteArray("410").getBytes()), ((ArrayList<ByteArrayRange>) l1).get(1)); }
public ByteArrayRange union(final ByteArrayRange other) { return new ByteArrayRange( ByteArrayUtils.compare(start, other.start) <= 0 ? start : other.start, ByteArrayUtils.compare(getEndAsNextPrefix(), other.getEndAsNextPrefix()) >= 0 ? end : other.end); }
ByteArrayRange implements Comparable<ByteArrayRange> { public ByteArrayRange union(final ByteArrayRange other) { return new ByteArrayRange( ByteArrayUtils.compare(start, other.start) <= 0 ? start : other.start, ByteArrayUtils.compare(getEndAsNextPrefix(), other.getEndAsNextPrefix()) >= 0 ? end : other.end); } }
ByteArrayRange implements Comparable<ByteArrayRange> { public ByteArrayRange union(final ByteArrayRange other) { return new ByteArrayRange( ByteArrayUtils.compare(start, other.start) <= 0 ? start : other.start, ByteArrayUtils.compare(getEndAsNextPrefix(), other.getEndAsNextPrefix()) >= 0 ? end : other.end); } ByteArrayRange(final byte[] start, final byte[] end);  ByteArrayRange(final byte[] start, final byte[] end, final boolean singleValue); }
ByteArrayRange implements Comparable<ByteArrayRange> { public ByteArrayRange union(final ByteArrayRange other) { return new ByteArrayRange( ByteArrayUtils.compare(start, other.start) <= 0 ? start : other.start, ByteArrayUtils.compare(getEndAsNextPrefix(), other.getEndAsNextPrefix()) >= 0 ? end : other.end); } ByteArrayRange(final byte[] start, final byte[] end);  ByteArrayRange(final byte[] start, final byte[] end, final boolean singleValue); byte[] getStart(); byte[] getEnd(); byte[] getEndAsNextPrefix(); boolean isSingleValue(); @Override int hashCode(); @Override boolean equals(final Object obj); boolean intersects(final ByteArrayRange other); ByteArrayRange intersection(final ByteArrayRange other); ByteArrayRange union(final ByteArrayRange other); @Override int compareTo(final ByteArrayRange other); static final Collection<ByteArrayRange> mergeIntersections(
      final Collection<ByteArrayRange> ranges,
      final MergeOperation op); }
ByteArrayRange implements Comparable<ByteArrayRange> { public ByteArrayRange union(final ByteArrayRange other) { return new ByteArrayRange( ByteArrayUtils.compare(start, other.start) <= 0 ? start : other.start, ByteArrayUtils.compare(getEndAsNextPrefix(), other.getEndAsNextPrefix()) >= 0 ? end : other.end); } ByteArrayRange(final byte[] start, final byte[] end);  ByteArrayRange(final byte[] start, final byte[] end, final boolean singleValue); byte[] getStart(); byte[] getEnd(); byte[] getEndAsNextPrefix(); boolean isSingleValue(); @Override int hashCode(); @Override boolean equals(final Object obj); boolean intersects(final ByteArrayRange other); ByteArrayRange intersection(final ByteArrayRange other); ByteArrayRange union(final ByteArrayRange other); @Override int compareTo(final ByteArrayRange other); static final Collection<ByteArrayRange> mergeIntersections(
      final Collection<ByteArrayRange> ranges,
      final MergeOperation op);  }