@Test void splitASingletonRangeShouldReturnASingleRange() { MessageRange one = MessageUid.of(1).toRange(); List<MessageRange> ranges = one.split(2); assertThat(ranges).containsExactly(MessageUid.of(1).toRange()); }
public List<MessageRange> split(int maxItems) { List<MessageRange> ranges = new ArrayList<>(); if (getType() == Type.RANGE) { long from = getUidFrom().asLong(); long to = getUidTo().asLong(); long realTo = to; while (from <= realTo) { to = Math.min(from + maxItems - 1, realTo); if (from == to) { ranges.add(MessageUid.of(from).toRange()); } else { ranges.add(MessageRange.range(MessageUid.of(from), MessageUid.of(to))); } from = to + 1; } } else { ranges.add(this); } return ranges; }
MessageRange implements Iterable<MessageUid> { public List<MessageRange> split(int maxItems) { List<MessageRange> ranges = new ArrayList<>(); if (getType() == Type.RANGE) { long from = getUidFrom().asLong(); long to = getUidTo().asLong(); long realTo = to; while (from <= realTo) { to = Math.min(from + maxItems - 1, realTo); if (from == to) { ranges.add(MessageUid.of(from).toRange()); } else { ranges.add(MessageRange.range(MessageUid.of(from), MessageUid.of(to))); } from = to + 1; } } else { ranges.add(this); } return ranges; } }
MessageRange implements Iterable<MessageUid> { public List<MessageRange> split(int maxItems) { List<MessageRange> ranges = new ArrayList<>(); if (getType() == Type.RANGE) { long from = getUidFrom().asLong(); long to = getUidTo().asLong(); long realTo = to; while (from <= realTo) { to = Math.min(from + maxItems - 1, realTo); if (from == to) { ranges.add(MessageUid.of(from).toRange()); } else { ranges.add(MessageRange.range(MessageUid.of(from), MessageUid.of(to))); } from = to + 1; } } else { ranges.add(this); } return ranges; } protected  MessageRange(Type type, MessageUid minValue, MessageUid maxValue); }
MessageRange implements Iterable<MessageUid> { public List<MessageRange> split(int maxItems) { List<MessageRange> ranges = new ArrayList<>(); if (getType() == Type.RANGE) { long from = getUidFrom().asLong(); long to = getUidTo().asLong(); long realTo = to; while (from <= realTo) { to = Math.min(from + maxItems - 1, realTo); if (from == to) { ranges.add(MessageUid.of(from).toRange()); } else { ranges.add(MessageRange.range(MessageUid.of(from), MessageUid.of(to))); } from = to + 1; } } else { ranges.add(this); } return ranges; } protected  MessageRange(Type type, MessageUid minValue, MessageUid maxValue); static MessageRange one(MessageUid uid); static MessageRange all(); static MessageRange range(MessageUid from, MessageUid to); static MessageRange from(MessageUid from); Type getType(); MessageUid getUidFrom(); MessageUid getUidTo(); boolean includes(MessageUid uid); String toString(); static List<MessageRange> toRanges(Collection<MessageUid> uidsCol); @Override Iterator<MessageUid> iterator(); List<MessageRange> split(int maxItems); @Override int hashCode(); @Override boolean equals(Object obj); }
MessageRange implements Iterable<MessageUid> { public List<MessageRange> split(int maxItems) { List<MessageRange> ranges = new ArrayList<>(); if (getType() == Type.RANGE) { long from = getUidFrom().asLong(); long to = getUidTo().asLong(); long realTo = to; while (from <= realTo) { to = Math.min(from + maxItems - 1, realTo); if (from == to) { ranges.add(MessageUid.of(from).toRange()); } else { ranges.add(MessageRange.range(MessageUid.of(from), MessageUid.of(to))); } from = to + 1; } } else { ranges.add(this); } return ranges; } protected  MessageRange(Type type, MessageUid minValue, MessageUid maxValue); static MessageRange one(MessageUid uid); static MessageRange all(); static MessageRange range(MessageUid from, MessageUid to); static MessageRange from(MessageUid from); Type getType(); MessageUid getUidFrom(); MessageUid getUidTo(); boolean includes(MessageUid uid); String toString(); static List<MessageRange> toRanges(Collection<MessageUid> uidsCol); @Override Iterator<MessageUid> iterator(); List<MessageRange> split(int maxItems); @Override int hashCode(); @Override boolean equals(Object obj);  }