001/*
002 * (C) Copyright 2013 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 *     dmetzler
018 */
019package org.nuxeo.ecm.automation.jaxrs.io.documents;
020
021import java.util.ArrayList;
022import java.util.Map;
023
024import org.nuxeo.ecm.automation.core.util.Paginable;
025import org.nuxeo.ecm.platform.query.api.Aggregate;
026import org.nuxeo.ecm.platform.query.api.Bucket;
027
028/**
029 * Paginable object that uses a delegate to handle pagination.
030 *
031 * @since 5.8
032 */
033public class PaginableWithDelegate<T> extends ArrayList<T> implements Paginable<T> {
034
035    private static final long serialVersionUID = 1L;
036
037    private Paginable<T> delegate;
038
039    /**
040     * @param delegate
041     */
042    public PaginableWithDelegate(Paginable<T> delegate) {
043        this.delegate = delegate;
044    }
045
046    @Override
047    public long getPageSize() {
048        return delegate.getPageSize();
049    }
050
051    @Override
052    public long getMaxPageSize() {
053        return delegate.getMaxPageSize();
054    }
055
056    @Override
057    public long getResultsCount() {
058        return delegate.getResultsCount();
059    }
060
061    @Override
062    public long getNumberOfPages() {
063        return delegate.getNumberOfPages();
064    }
065
066    @Override
067    public boolean isNextPageAvailable() {
068        return delegate.isNextPageAvailable();
069    }
070
071    @Override
072    public boolean isLastPageAvailable() {
073        return delegate.isLastPageAvailable();
074    }
075
076    @Override
077    public boolean isPreviousPageAvailable() {
078        return delegate.isPreviousPageAvailable();
079    }
080
081    @Override
082    public long getCurrentPageSize() {
083        return delegate.getCurrentPageSize();
084    }
085
086    @Override
087    public long getCurrentPageIndex() {
088        return delegate.getCurrentPageIndex();
089    }
090
091    @Override
092    public boolean isSortable() {
093        return delegate.isSortable();
094    }
095
096    @Override
097    public boolean hasError() {
098        return delegate.hasError();
099    }
100
101    @Override
102    public String getErrorMessage() {
103        return delegate.getErrorMessage();
104    }
105
106    @Override
107    public Map<String, Aggregate<? extends Bucket>> getAggregates() {
108        return delegate.getAggregates();
109    }
110
111    @Override
112    public boolean hasAggregateSupport() {
113        return delegate.hasAggregateSupport();
114    }
115
116}