public static <T> boolean isEmpty(BatchingVisitable<T> v) { return v.batchAccept(1, AbortingVisitors.<T, RuntimeException>batching(AbortingVisitors.<T>alwaysFalse())); }
@Test public void testEmpty() { assertTrue("empty batching visitable should be empty!", BatchingVisitables.isEmpty(BatchingVisitables.emptyBatchingVisitable())); assertEquals("empty batching visitable should be empty!", 0, BatchingVisitables.count(BatchingVisitables.emptyBatchingVisitable())); BatchingVisitable<Long> bv = ListVisitor.create(Lists.newArrayList(0L, 1L, 2L, 3L)); assertFalse("non-empty batching visitable should not be empty!", BatchingVisitables.isEmpty(bv)); assertEquals("visitable had wrong size", 4, BatchingVisitables.count(bv)); assertTrue("empty visitable should always be true, even when told to visit an always-false place", BatchingVisitables.emptyBatchingVisitable().batchAccept(1, AbortingVisitors.alwaysFalse())); }
public static <T> boolean isEmpty(BatchingVisitable<T> v) { return v.batchAccept(1, AbortingVisitors.<T, RuntimeException>batching(AbortingVisitors.<T>alwaysFalse())); }
assertEquals("limit produced unexpected result", ImmutableList.of(0L, 1L, 2L), copy); assertFalse("alwaysFalse should be false", limited.batchAccept(1, AbortingVisitors.alwaysFalse())); assertTrue("alwaysTrue should be true", limited.batchAccept(1, AbortingVisitors.alwaysTrue())); limited.skip(3).batchAccept(1, AbortingVisitors.alwaysFalse())); .batchAccept(1, AbortingVisitors.alwaysFalse())); assertTrue("batchAccept should be trivially true after everything was skipped", limited.hintBatchSize(10).skip(3) .batchAccept(1, AbortingVisitors.alwaysFalse()));