Java List First Item limit(List list, Long firstResult, Long maxResults)

Here you can find the source of limit(List list, Long firstResult, Long maxResults)

Description

limit

License

Open Source License

Declaration

public static <T> List<T> limit(List<T> list, Long firstResult, Long maxResults) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    public static <T> List<T> limit(List<T> list, Long firstResult, Long maxResults) {
        return limit(list, firstResult != null ? firstResult.intValue() : null,
                maxResults != null ? maxResults.intValue() : null);
    }//  w  w w . java2 s. c om

    public static <T> List<T> limit(List<T> list, Integer firstResult, Integer maxResults) {
        int resultCount = list.size();
        int firstIndex = firstResult == null ? 0 : Math.min(firstResult.intValue(), resultCount);
        int toIndex = maxResults == null ? resultCount : Math.min(firstIndex + maxResults.intValue(), resultCount);
        return list.subList(firstIndex, toIndex);
    }
}

Related

  1. hasSameElement(List firstList, List secondList)
  2. isFirst(List list, V object)
  3. isFirstAnnotationOfMethod(List lines, int lineNumber)
  4. isFirstPage(List pageLines, List> rawPages)
  5. isInOrder(List src, Object first, Object second)
  6. listWith(Object aFirstObject)
  7. merge(List first, List second)
  8. mergeLists(List first, List second)
  9. mergeLists(List first, List second)