Package org.springframework.data.domain

Examples of org.springframework.data.domain.PageImpl


    @SuppressWarnings({"unchecked", "rawtypes"})
    protected Object createPage(Iterable<?> result, Pageable pageable, Long count, boolean isPageQuery) {
        final List resultList = IteratorUtil.addToCollection(result, new ArrayList());
        if (pageable==null) {
            return isPageQuery ? new PageImpl(resultList) : new SliceImpl(resultList);
        }
        int pageSize = pageable.getPageSize();
        int requestedCountStart = pageable.getOffset();
        int resultSize = resultList.size();
        int currentTotal;
        if (count!=null) {
            currentTotal = count.intValue();
        } else {
            if (resultSize == pageSize) currentTotal = requestedCountStart + pageSize;
            else currentTotal = requestedCountStart + resultSize;
        }
        int resultWindowSize = Math.min(resultSize, pageSize);
        boolean hasNext = resultWindowSize < resultSize;
        List resultListPage = resultList.subList(0, resultWindowSize);

        return isPageQuery ?
                new PageImpl(resultListPage, pageable, currentTotal) :
                new SliceImpl(resultListPage,pageable, hasNext);
    }
View Full Code Here


    }

    private Page<?> selectPage(List<Object> items, Pageable pageable) {
        final List<Object> itemsOnPage = items.subList(pageable.getOffset(), Math.min(items.size(), pageable.getOffset() + pageable.getPageSize()));

        return new PageImpl(itemsOnPage, pageable, items.size());
    }
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.PageImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.