code: public static List<Range<Long>> getLongRanges(final Long from, final Long to, final int step)
        throws InvalidRangeException {
  
      if (from > to) {
        throw buildInvalidRangeException(from, to);
      }
      ArrayList<Range<Long>> list = newArrayList();
      if (step >= to - from) {
        list.add(Range.getInstance(from, to));
      } else {
        for (Long currentSpan = from; currentSpan <= to; ) {
          Long lowerBound = currentSpan;
          Long tempUpperBound = currentSpan + (step > 1 ? step - 1 : 0);
          Long upperBound = tempUpperBound > to ? to : tempUpperBound;
          list.add(Range.getInstance(lowerBound, upperBound));
          currentSpan += step > 0 ? step : 1;
        }
      }
      return list;
    }
docs: Returns Range&lt;Long&gt; list between given from and to by step.The
  minimum step is 1.<br/>
  e.g:<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;[from:0,to:3,step:1] => [[0-0],[1-1],[2-2],[3-3]]<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;[from:0,to:7,step:2] => [[0-1],[2-3],[4-5],[6-7]]<br/>
  &nbsp;&nbsp;&nbsp;&nbsp;[from:0,to:7,step:3] => [[0-2],[3-5],[6-7]]<br/>
  
  @param from the range from.
  @param to the range to.
  @param step the range granulation.
  @return a Range&lt;Long&gt; list between given from and to by step.