public static < K , V > List < Map < K , V > > split ( Map < K , V > map , int limit ) { Assert . notNull ( map , "Missing map!" ) ; Assert . isTrue ( limit > 0 , "Map limit must be > 0!" ) ; if ( map . size ( ) <= limit ) { return Collections . singletonList ( map ) ; // nothing to do } return map . entrySet ( ) . parallelStream ( ) . collect ( mapSizer ( limit ) ) ; }
Splits map to list of maps