code: public static <T> List<T> subList(final List<T> list, int pageSize, int page) {
  
  		if (pageSize <= 0 || page == 0) {
  
  			return Collections.EMPTY_LIST;
  		}
  
  		int size        = list.size();
  
  		int fromIndex   = page > 0
  		     ? (page - 1) * pageSize
  		     : size + (page * pageSize);
  
  		int toIndex = fromIndex + pageSize;
  
  		int finalFromIndex = Math.max(0, fromIndex);
  		int finalToIndex   =  Math.min(size, Math.max(0, toIndex));
  
  		// prevent fromIndex to be greater than toIndex
  		if (finalFromIndex > finalToIndex) {
  			finalFromIndex = finalToIndex;
  		}
  
  		try {
  			return list.subList(finalFromIndex, finalToIndex);
  
  		} catch (Throwable t) {
  
  			logger.warn("Invalid range for sublist in paging, pageSize {}, page {}: {}", new Object[] {
  				pageSize,
  				page,
  				t.getMessage()
  			});
  		}
  
  		return Collections.EMPTY_LIST;
  
  	}
docs: Return a single page of the list with the given paging parameters.
  
  @param list
  @param pageSize
  @param page
  @return subList