001/*
002 * (C) Copyright 2016 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 *     Antoine Taillefer <ataillefer@nuxeo.com>
018 */
019package org.nuxeo.drive.adapter.impl;
020
021import java.util.ArrayList;
022import java.util.List;
023
024import org.codehaus.jackson.map.annotate.JsonDeserialize;
025import org.nuxeo.drive.adapter.FileSystemItem;
026import org.nuxeo.drive.adapter.ScrollFileSystemItemList;
027
028/**
029 * Default implementation of a {@link ScrollFileSystemItemList} based on an {@link ArrayList}.
030 *
031 * @since 8.3
032 */
033@JsonDeserialize(using = ScrollFileSystemItemListDeserializer.class)
034public class ScrollFileSystemItemListImpl extends ArrayList<FileSystemItem> implements ScrollFileSystemItemList {
035
036    private static final long serialVersionUID = 8703448908774574014L;
037
038    protected String scrollId;
039
040    public ScrollFileSystemItemListImpl() {
041        // Needed for JSON deserialization
042    }
043
044    public ScrollFileSystemItemListImpl(String scrollId, int size) {
045        super(size);
046        this.scrollId = scrollId;
047    }
048
049    public ScrollFileSystemItemListImpl(String scrollId, List<FileSystemItem> list) {
050        super(list);
051        this.scrollId = scrollId;
052    }
053
054    @Override
055    public String getScrollId() {
056        return scrollId;
057    }
058
059    @Override
060    public void setScrollId(String scrollId) {
061        this.scrollId = scrollId;
062    }
063
064    @Override
065    public String toString() {
066        return String.format("scrollId = %s, fileSystemItems = %s", scrollId, super.toString());
067    }
068}