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 <[email protected]> 018 */ 019package org.nuxeo.drive.adapter.impl; 020 021import java.util.ArrayList; 022import java.util.List; 023 024import org.nuxeo.drive.adapter.FileSystemItem; 025import org.nuxeo.drive.adapter.ScrollFileSystemItemList; 026 027import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 028 029/** 030 * Default implementation of a {@link ScrollFileSystemItemList} based on an {@link ArrayList}. 031 * 032 * @since 8.3 033 */ 034@JsonDeserialize(using = ScrollFileSystemItemListDeserializer.class) 035public class ScrollFileSystemItemListImpl extends ArrayList<FileSystemItem> implements ScrollFileSystemItemList { 036 037 private static final long serialVersionUID = 8703448908774574014L; 038 039 protected String scrollId; 040 041 public ScrollFileSystemItemListImpl() { 042 // Needed for JSON deserialization 043 } 044 045 public ScrollFileSystemItemListImpl(String scrollId, int size) { 046 super(size); 047 this.scrollId = scrollId; 048 } 049 050 public ScrollFileSystemItemListImpl(String scrollId, List<FileSystemItem> list) { 051 super(list); 052 this.scrollId = scrollId; 053 } 054 055 @Override 056 public String getScrollId() { 057 return scrollId; 058 } 059 060 @Override 061 public void setScrollId(String scrollId) { 062 this.scrollId = scrollId; 063 } 064 065 // Override equals and hashCode to explicitly show that their implementation rely on the parent class and doesn't 066 // depend on the fields added to this class. 067 @Override 068 public boolean equals(Object obj) { 069 return super.equals(obj); 070 } 071 072 @Override 073 public int hashCode() { 074 return super.hashCode(); 075 } 076 077 @Override 078 public String toString() { 079 return String.format("scrollId = %s, fileSystemItems = %s", scrollId, super.toString()); 080 } 081}