001/*
002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo
018 */
019package org.nuxeo.ecm.automation.core.util;
020
021import java.util.List;
022import java.util.Map;
023
024import org.nuxeo.ecm.platform.query.api.Aggregate;
025import org.nuxeo.ecm.platform.query.api.Bucket;
026import org.nuxeo.ecm.platform.query.api.QuickFilter;
027
028/**
029 * @author <a href="mailto:tdelprat@nuxeo.com">Tiry</a>
030 * @since 5.7 (extracted from PaginableDocumentModelList)
031 */
032public interface Paginable<T> extends List<T> {
033
034    /**
035     * Returns the number of results per page. 0 means no pagination.
036     */
037    long getPageSize();
038
039    /**
040     * Returns the max number of results per page. 0 means no pagination.
041     * <p>
042     * If page size is greater than this maximum value, it will be taken into account instead.
043     */
044    long getMaxPageSize();
045
046    /**
047     * Returns the number of result elements if available or a negative value if it is unknown:
048     * <code>UNKNOWN_SIZE</code> if it is unknown as query was not done, and since 5.5,
049     * <code>UNKNOWN_SIZE_AFTER_QUERY</code> if it is still unknown after query was done.
050     */
051    long getResultsCount();
052
053    /**
054     * Returns the total number of pages or 0 if number of pages is unknown.
055     */
056    long getNumberOfPages();
057
058    /**
059     * Returns a boolean expressing if there are further pages.
060     */
061    boolean isNextPageAvailable();
062
063    /**
064     * Returns a boolean expressing if the last page can be displayed.
065     */
066    boolean isLastPageAvailable();
067
068    /**
069     * Returns a boolean expressing if there is a previous page.
070     */
071    boolean isPreviousPageAvailable();
072
073    /**
074     * Returns the number of elements in current page.
075     */
076    long getCurrentPageSize();
077
078    /**
079     * Returns the current page index as a zero-based integer.
080     */
081    long getCurrentPageIndex();
082
083    /**
084     * Returns if this provider is sortable.
085     */
086    boolean isSortable();
087
088    boolean hasError();
089
090    String getErrorMessage();
091
092    /**
093     * @since 6.0
094     */
095    Map<String, Aggregate<? extends Bucket>> getAggregates();
096
097    /**
098     * @since 6.0
099     */
100    boolean hasAggregateSupport();
101
102    /**
103     * @since 8.4
104     */
105    List<QuickFilter> getActiveQuickFilters();
106
107    /**
108     * @since 8.4
109     */
110    List<QuickFilter> getAvailableQuickFilters();
111
112}