@Test public void batchSizeOfOneAlwaysPerformsOperation() { batcher = new TestBatcher(1); assertEquals(0, operationCount); assertEquals(1, resetCount); batcher.operate(); assertEquals(1, operationCount); assertEquals(2, resetCount); batcher.operate(); assertEquals(2, operationCount); assertEquals(3, resetCount); }
public void operate() { if (closed) { throw new IllegalStateException("Batcher closed"); } if (++count < batchSize) { return; } operation(); reset(); count = 0; }
OperationBatcher { public void operate() { if (closed) { throw new IllegalStateException("Batcher closed"); } if (++count < batchSize) { return; } operation(); reset(); count = 0; } }
OperationBatcher { public void operate() { if (closed) { throw new IllegalStateException("Batcher closed"); } if (++count < batchSize) { return; } operation(); reset(); count = 0; } OperationBatcher(int batchSize); }
OperationBatcher { public void operate() { if (closed) { throw new IllegalStateException("Batcher closed"); } if (++count < batchSize) { return; } operation(); reset(); count = 0; } OperationBatcher(int batchSize); void operate(); void close(); }
OperationBatcher { public void operate() { if (closed) { throw new IllegalStateException("Batcher closed"); } if (++count < batchSize) { return; } operation(); reset(); count = 0; } OperationBatcher(int batchSize); void operate(); void close();  }