code: public static <E extends Comparable<E>> List<Range<E>> getRanges(Collection<E> collection,
        int batchSize) {
  
      List<Range<E>> rangeList = new LinkedList<Range<E>>();
  
      E currentMin = null;
  
      // Check for edge cases
      if ((collection != null) && (collection.size() > 0) && (batchSize > 0)) {
  
        int index = 1;
        for (E element : collection) {
          // Bootstrap first element in the next range
          if (currentMin == null) {
            currentMin = element;
          }
  
          int mod = index % batchSize;
          // On each batchSize items (and the last one) create a range
          if ((mod == 0) || (index == collection.size())) {
            Range<E> range = new Range<E>(currentMin, element);
            rangeList.add(range);
            currentMin = null;
          }
  
          index++;
        }
      }
  
      return rangeList;
    }
docs: Given an (ordered) {@link Collection} of non-<code>null</code>, iterate
  over the collection and return a list of ranges of the given batchSize. The
  last range may be smaller and contains the remainder if the collection is
  not equally divisible in batchSize ranges.
  
  @param <E>
  The class of Elements in the collection out of which to create
  ranges.
  
  @param collection
  of non-<code>null</code> elements to chop up in ranges.
  @param batchSize
  the size to chop the collection into. Must be larger than
  <code>1</code> and can be larger than the collection.
  @return a non-null list of ranges.
  <p>
  For example, <code>getRanges([1,2,3], 1)</code> is
  <code>[1-1,2-2,3-3]</code> and
  <code>getRanges([1,2,3,4,5,6,7,8,9,10], 3)</code> is
  <code>[1-3,4-6,7-9,10-10]</code> and
  <code>getRanges([1,2,3,4,5,6,7,8,9,10], 17)</code> is
  <code>[1-10]</code>