Created
May 3, 2013 05:04
-
-
Save sudarshan89/5507303 to your computer and use it in GitHub Desktop.
Proposed API for Pagination, this interface encapsulates the information to display information related to pagination.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.nthdimenzion.cqrs.query; | |
import java.util.Iterator; | |
import java.util.List; | |
/** | |
* A page is a sublist of a list of objects. It allows gain information about | |
* the position of it in the containing entire list. | |
* | |
* @author Oliver Gierke | |
* @param <T> | |
*/ | |
public interface IPage<T> extends Iterable<T> { | |
/** | |
* Returns the number of the current page. Is always positive and less that | |
* {@code Page#getTotalPages()}. | |
* | |
* @return the number of the current page | |
*/ | |
int getNumber(); | |
/** | |
* Returns the size of the page. | |
* | |
* @return the size of the page | |
*/ | |
int getSize(); | |
/** | |
* Returns the number of total pages. | |
* | |
* @return the number of toral pages | |
*/ | |
int getTotalPages(); | |
/** | |
* Returns the number of elements currently on this page. | |
* | |
* @return the number of elements currently on this page | |
*/ | |
int getNumberOfElements(); | |
/** | |
* Returns the total amount of elements. | |
* | |
* @return the total amount of elements | |
*/ | |
long getTotalElements(); | |
/** | |
* Returns if there is a previous page. | |
* | |
* @return if there is a previous page | |
*/ | |
boolean hasPreviousPage(); | |
/** | |
* Returns whether the current page is the first one. | |
* | |
* @return | |
*/ | |
boolean isFirstPage(); | |
/** | |
* Returns if there is a next page. | |
* | |
* @return if there is a next page | |
*/ | |
boolean hasNextPage(); | |
/** | |
* Returns whether the current page is the last one. | |
* | |
* @return | |
*/ | |
boolean isLastPage(); | |
/* | |
* (non-Javadoc) | |
* | |
* @see java.lang.Iterable#iterator() | |
*/ | |
Iterator<T> iterator(); | |
/** | |
* Returns the page content as {@link java.util.List}. | |
* | |
* @return | |
*/ | |
List<T> getContent(); | |
/** | |
* Returns whether the {@link IPage} has content at all. | |
* | |
* @return | |
*/ | |
boolean hasContent(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment