@Test public void testList() { final BuildDetails result1 = new BuildDetails(); final BuildDetails result2 = new BuildDetails(); final BuildDetails result3 = new BuildDetails(); final BuildDetails result4 = new BuildDetails(); final BuildDetails result5 = new BuildDetails(); buildService.save(result1); buildService.save(result2); buildService.save(result3); buildService.save(result4); buildService.save(result5); assertEquals(2, buildService.list(result2.getUuid(), 3).size()); assertEquals(3, buildService.list(null, 3).size()); assertEquals(3, buildService.list(result5.getUuid(), 3).size()); assertNull(buildService.list(randomUUID().toString(), 3)); }
public List<BuildSummary> list(final String from, final int requestSize) { int fromIndex = (null == from) ? 0 : uuids.indexOf(from); int toIndex = Math.min(fromIndex + requestSize, uuids.size()); if (fromIndex < 0) { return null; } else { return uuids.subList(fromIndex, toIndex).stream() .map(uuid2buildResult::get) .map(BuildDetails::getSummary) .collect(toList()); } }
BuildService extends AbstractService { public List<BuildSummary> list(final String from, final int requestSize) { int fromIndex = (null == from) ? 0 : uuids.indexOf(from); int toIndex = Math.min(fromIndex + requestSize, uuids.size()); if (fromIndex < 0) { return null; } else { return uuids.subList(fromIndex, toIndex).stream() .map(uuid2buildResult::get) .map(BuildDetails::getSummary) .collect(toList()); } } }
BuildService extends AbstractService { public List<BuildSummary> list(final String from, final int requestSize) { int fromIndex = (null == from) ? 0 : uuids.indexOf(from); int toIndex = Math.min(fromIndex + requestSize, uuids.size()); if (fromIndex < 0) { return null; } else { return uuids.subList(fromIndex, toIndex).stream() .map(uuid2buildResult::get) .map(BuildDetails::getSummary) .collect(toList()); } }  }
BuildService extends AbstractService { public List<BuildSummary> list(final String from, final int requestSize) { int fromIndex = (null == from) ? 0 : uuids.indexOf(from); int toIndex = Math.min(fromIndex + requestSize, uuids.size()); if (fromIndex < 0) { return null; } else { return uuids.subList(fromIndex, toIndex).stream() .map(uuid2buildResult::get) .map(BuildDetails::getSummary) .collect(toList()); } }  void addListener(final DangerousConsumer<BuildSummary> listener); void save(final BuildDetails buildDetails); Optional<BuildDetails> get(final String uuid); List<BuildSummary> list(final String from, final int requestSize); }
BuildService extends AbstractService { public List<BuildSummary> list(final String from, final int requestSize) { int fromIndex = (null == from) ? 0 : uuids.indexOf(from); int toIndex = Math.min(fromIndex + requestSize, uuids.size()); if (fromIndex < 0) { return null; } else { return uuids.subList(fromIndex, toIndex).stream() .map(uuid2buildResult::get) .map(BuildDetails::getSummary) .collect(toList()); } }  void addListener(final DangerousConsumer<BuildSummary> listener); void save(final BuildDetails buildDetails); Optional<BuildDetails> get(final String uuid); List<BuildSummary> list(final String from, final int requestSize);  }