Combinations { public Combinations resize(List<Integer> newSeqSizes) { Preconditions.checkArgument(newSeqSizes.size() == seqSizes.size()); for (int i = 0; i < newSeqSizes.size(); i++) { Preconditions.checkArgument(newSeqSizes.get(i) >= seqSizes.get(i)); } return new Combinations(this, newSeqSizes); } private  Combinations(int tupleSize); private  Combinations(Combinations previous, List<Integer> newSeqSizes); int getSize(); int[] combinationAt(int pos); Combinations resize(List<Integer> newSeqSizes); static Combinations newInstance(int tupleSize);  }
@Test public void testResize() throws Exception { Combinations combinations = Combinations.newInstance(2) .resize(asList(2, 2)) .resize(asList(3, 3)); List<int[]> tuples = take(combinations, 9); assertThat(tuples.get(0)).isIn(COMBINATIONS_2x2); assertThat(tuples.get(1)).isIn(COMBINATIONS_2x2); assertThat(tuples).containsAll(COMBINATIONS_3x3); }