@Test public void testSubList() { GroupConfigEntryList list = new GroupConfigEntryList(); list.add(new AddNodeEntry(1, 1, Collections.<NodeEndpoint>emptySet(), new NodeEndpoint("A", "localhost", 2333))); list.add(new AddNodeEntry(4, 1, Collections.<NodeEndpoint>emptySet(), new NodeEndpoint("A", "localhost", 2333))); list.add(new AddNodeEntry(10, 1, Collections.<NodeEndpoint>emptySet(), new NodeEndpoint("A", "localhost", 2333))); Assert.assertEquals(0, list.subList(1, 1).size()); Assert.assertEquals(1, list.subList(10, 11).size()); Assert.assertEquals(3, list.subList(1, 11).size()); Assert.assertEquals(1, list.subList(1, 4).size()); Assert.assertEquals(2, list.subList(1, 5).size()); Assert.assertEquals(2, list.subList(4, 11).size()); Assert.assertEquals(1, list.subList(4, 10).size()); }
public List<GroupConfigEntry> subList(int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IllegalArgumentException("from index > to index"); } return entries.stream() .filter(e -> e.getIndex() >= fromIndex && e.getIndex() < toIndex) .collect(Collectors.toList()); }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public List<GroupConfigEntry> subList(int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IllegalArgumentException("from index > to index"); } return entries.stream() .filter(e -> e.getIndex() >= fromIndex && e.getIndex() < toIndex) .collect(Collectors.toList()); } }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public List<GroupConfigEntry> subList(int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IllegalArgumentException("from index > to index"); } return entries.stream() .filter(e -> e.getIndex() >= fromIndex && e.getIndex() < toIndex) .collect(Collectors.toList()); }  }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public List<GroupConfigEntry> subList(int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IllegalArgumentException("from index > to index"); } return entries.stream() .filter(e -> e.getIndex() >= fromIndex && e.getIndex() < toIndex) .collect(Collectors.toList()); }  GroupConfigEntry getLast(); void add(GroupConfigEntry entry); GroupConfigEntry removeAfter(int entryIndex); List<GroupConfigEntry> subList(int fromIndex, int toIndex); @Override @Nonnull Iterator<GroupConfigEntry> iterator(); @Override String toString(); }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public List<GroupConfigEntry> subList(int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new IllegalArgumentException("from index > to index"); } return entries.stream() .filter(e -> e.getIndex() >= fromIndex && e.getIndex() < toIndex) .collect(Collectors.toList()); }  GroupConfigEntry getLast(); void add(GroupConfigEntry entry); GroupConfigEntry removeAfter(int entryIndex); List<GroupConfigEntry> subList(int fromIndex, int toIndex); @Override @Nonnull Iterator<GroupConfigEntry> iterator(); @Override String toString();  }