class PaginationHelper {

    public static List<BaseDimensionalItemObject> slice( final WebOptions options,
        List<BaseDimensionalItemObject> dimensionalItems )
    {
        state( options.getPage() > 0, "Current page must be greater than zero." );
        state( options.getPageSize() > 0, "Page size must be greater than zero." );

        if ( options.hasPaging() && isNotEmpty( dimensionalItems ) )
        {
            // Pagination input
            final int currentPage = options.getPage();
            final int totalOfElements = dimensionalItems.size();
            final int maxElementsPerPage = options.getPageSize();

            final Pager pager = new Pager( currentPage, totalOfElements, maxElementsPerPage );

            final int currentElementIndex = pager.getOffset();
            final boolean hasMorePages = (totalOfElements - currentElementIndex) > pager.getPageSize();

            if ( hasMorePages )
            {
                final int nextElementsWindow = pager.getPageSize() * pager.getPage();
                dimensionalItems = dimensionalItems.subList( currentElementIndex, nextElementsWindow );
            }
            else
            {
                // This is the last page
                dimensionalItems = dimensionalItems.subList( pager.getOffset(), totalOfElements );
            }
        }

        return dimensionalItems;
    }

}