RepeatBlock implements Block { @Override public PieceCount getPieceCount() { return constantRepeatTimes ? block.getPieceCount().multiply(repeatTimes.get()) : PieceCount.createUnknownCount(); } RepeatBlock(final int repeatTimes, Block block);  RepeatBlock(IntSupplier repeatTimes, Block block); static Block unlimited(Block block); @Override Iterator<AbstractPiece> iterator(); @Override void forAllPossiblePieces(Consumer<AbstractPiece> consumer); @Override PieceCount getPieceCount(); @Override String toString();  }
@Test public void testRepeatBlockBasic() throws Exception { Piece piece1 = new Piece(); Piece piece2 = new Piece(); Block innerBlock = new SequenceBlock(piece1, piece2); Block repeatBlock = new RepeatBlock( REPEAT_TIMES, innerBlock ); BlockTestingUtils.testIndependence( Iterables.concat(Collections.nCopies(REPEAT_TIMES, Arrays.asList(piece1, piece2))), repeatBlock); Assert.assertEquals(REPEAT_TIMES * 2, repeatBlock.getPieceCount().getCount()); }