public static < U extends Aggregate > List < Batch < U > > getBatches ( List < U > list , int partitionSize ) { List < List < U >> partitions = Lists . partition ( list , partitionSize ) ; List < Batch < U > > split = new ArrayList <> ( ) ; for ( List < U > partition : partitions ) { split . add ( new Batch < U > ( partition ) ) ; } return split ; }
Helper method to create batch from list of aggregates for cases when list of aggregates is higher then batchLimit