@SuppressWarnings("unchecked")
   public static <K, V> List<Map<K, V>> splitMap(Map<K, V> _map, int _nbElements) throws InstantiationException, IllegalAccessException  {
       List<Map<K, V>> lofm = new ArrayList<>();
       lofm.add(_map.getClass().newInstance());
       for (Entry<K, V> e : _map.entrySet()) {
           Map<K, V> lastSubMap = lofm.get(lofm.size() - 1);
           if (lastSubMap.size() == _nbElements) {
               lofm.add(_map.getClass().newInstance());
               lastSubMap = lofm.get(lofm.size() - 1);
           }
           lastSubMap.put(e.getKey(), e.getValue());
       }
       return lofm;
   }
@ SuppressWarnings ( "unchecked" ) public static < K , V > List < Map < K , V > > splitMap ( Map < K , V > _map , int _nbElements ) throws InstantiationException , IllegalAccessException { List < Map < K , V > > lofm = new ArrayList < > ( ) ; lofm . add ( _map . getClass ( ) . newInstance ( ) ) ; for ( Entry < K , V > e : _map . entrySet ( ) ) { Map < K , V > lastSubMap = lofm . get ( lofm . size ( ) - 1 ) ; if ( lastSubMap . size ( ) == _nbElements ) { lofm . add ( _map . getClass ( ) . newInstance ( ) ) ; lastSubMap = lofm . get ( lofm . size ( ) - 1 ) ; } lastSubMap . put ( e . getKey ( ) , e . getValue ( ) ) ; } return lofm ; }
Splits _map to a list of maps where each map has _nbElements.
Last map in list maybe shorter if _map.size() is not divideable by _nElements.

@param _map map to split
@param _nbElements elements per map
@param <K> key type
@param <V> value type
@return List of Maps
@throws IllegalAccessException on error
@throws InstantiationException on error