CycleLogInput implements Input, AutoCloseable, Iterable<CycleResultsSegment>, CanFilterResultValue { @Override public synchronized CycleSegment getInputSegment(int segmentLength) { CycleSegmentBuffer csb = new CycleSegmentBuffer(segmentLength); while (csb.remaining() > 0) { while (!segmentIter.hasNext() && cycleResultSegmentIterator.hasNext()) { segmentIter = cycleResultSegmentIterator.next().iterator(); } if (segmentIter.hasNext()) { CycleResult cycleResult = segmentIter.next(); if (filter==null || filter.test(cycleResult)) { csb.append(cycleResult.getCycle()); } } else { if (csb.remaining() == segmentLength) { return null; } else { break; } } } return csb.toReadable(); } CycleLogInput(Activity activity);  CycleLogInput(String filename); @Override void setFilter(Predicate<ResultReadable> filter); @Override synchronized CycleSegment getInputSegment(int segmentLength); @Override void close(); @Override Iterator<CycleResultsSegment> iterator();  }
@Test public void testReader() { CycleLogInput cycleLogInput = new CycleLogInput(cyclefile.getPath()); CycleSegment i1; long c; i1 = cycleLogInput.getInputSegment(1); c = i1.nextCycle(); assertThat(c).isEqualTo(1L); i1 = cycleLogInput.getInputSegment(1); c = i1.nextCycle(); assertThat(c).isEqualTo(2L); i1 = cycleLogInput.getInputSegment(1); c = i1.nextCycle(); assertThat(c).isEqualTo(3L); i1 = cycleLogInput.getInputSegment(1); c = i1.nextCycle(); assertThat(c).isEqualTo(4L); i1 = cycleLogInput.getInputSegment(1); c = i1.nextCycle(); assertThat(c).isEqualTo(5L); assertThat(i1.isExhausted()).isTrue(); }