NestedLoopPairIterable implements Iterable<Pair<P, Q>> { public static <P, Q> NestedLoopPairIterable<P, Q> of(Iterable<P> outerSource, Iterable<Q> innerSource) { return new NestedLoopPairIterable<>(outerSource, innerSource); } private  NestedLoopPairIterable(Iterable<P> outerSource, Iterable<Q> innerSource); static NestedLoopPairIterable<P, Q> of(Iterable<P> outerSource, Iterable<Q> innerSource); @Override Iterator<Pair<P, Q>> iterator();  }
@Test public void shouldReturnEmptyIfInnerIsEmpty() throws Exception { ImmutableList<String> a = ImmutableList.of("a", "b"); ImmutableList<Integer> b = ImmutableList.of(); NestedLoopPairIterable<String, Integer> ible = NestedLoopPairIterable.of(a, b); assertEquals(0, size(ible)); }
@Test public void shouldReturnEmptyIfOuterIsEmpty() throws Exception { ImmutableList<Integer> a = ImmutableList.of(); ImmutableList<String> b = ImmutableList.of("a", "b"); NestedLoopPairIterable<Integer, String> ible = NestedLoopPairIterable.of(a, b); assertEquals(0, size(ible)); }
@Test public void shouldReturnEmptyIfBothAreEmpty() throws Exception { ImmutableList<Integer> a = ImmutableList.of(); ImmutableList<String> b = ImmutableList.of(); NestedLoopPairIterable<Integer, String> ible = NestedLoopPairIterable.of(a, b); assertEquals(0, size(ible)); }