001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * dmetzler 016 */ 017package org.nuxeo.ecm.automation.jaxrs.io.documents; 018 019import java.util.ArrayList; 020import java.util.Map; 021 022import org.nuxeo.ecm.automation.core.util.Paginable; 023import org.nuxeo.ecm.platform.query.api.Aggregate; 024import org.nuxeo.ecm.platform.query.api.Bucket; 025 026/** 027 * Paginable object that uses a delegate to handle pagination. 028 * 029 * @since 5.8 030 */ 031public class PaginableWithDelegate<T> extends ArrayList<T> implements Paginable<T> { 032 033 private static final long serialVersionUID = 1L; 034 035 private Paginable<T> delegate; 036 037 /** 038 * @param delegate 039 */ 040 public PaginableWithDelegate(Paginable<T> delegate) { 041 this.delegate = delegate; 042 } 043 044 @Override 045 public long getPageSize() { 046 return delegate.getPageSize(); 047 } 048 049 @Override 050 public long getMaxPageSize() { 051 return delegate.getMaxPageSize(); 052 } 053 054 @Override 055 public long getResultsCount() { 056 return delegate.getResultsCount(); 057 } 058 059 @Override 060 public long getNumberOfPages() { 061 return delegate.getNumberOfPages(); 062 } 063 064 @Override 065 public boolean isNextPageAvailable() { 066 return delegate.isNextPageAvailable(); 067 } 068 069 @Override 070 public boolean isLastPageAvailable() { 071 return delegate.isLastPageAvailable(); 072 } 073 074 @Override 075 public boolean isPreviousPageAvailable() { 076 return delegate.isPreviousPageAvailable(); 077 } 078 079 @Override 080 public long getCurrentPageSize() { 081 return delegate.getCurrentPageSize(); 082 } 083 084 @Override 085 public long getCurrentPageIndex() { 086 return delegate.getCurrentPageIndex(); 087 } 088 089 @Override 090 public boolean isSortable() { 091 return delegate.isSortable(); 092 } 093 094 @Override 095 public boolean hasError() { 096 return delegate.hasError(); 097 } 098 099 @Override 100 public String getErrorMessage() { 101 return delegate.getErrorMessage(); 102 } 103 104 @Override 105 public Map<String, Aggregate<? extends Bucket>> getAggregates() { 106 return delegate.getAggregates(); 107 } 108 109 @Override 110 public boolean hasAggregateSupport() { 111 return delegate.hasAggregateSupport(); 112 } 113 114}