001/* 002 * #%L 003 * GwtMaterial 004 * %% 005 * Copyright (C) 2015 - 2016 GwtMaterialDesign 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package gwt.material.design.client.data.loader; 021 022import java.util.List; 023import gwt.material.design.client.data.DataView; 024 025public class LoadResult<T> { 026 027 private final List<T> data; 028 private final int offset; 029 private final int totalLength; 030 private final boolean cacheData; 031 032 public LoadResult(List<T> data, int offset, int totalLength) { 033 this(data, offset, totalLength, true); 034 } 035 036 public LoadResult(List<T> data, int offset, int totalLength, boolean cacheData) { 037 this.data = data; 038 this.offset = offset; 039 this.totalLength = totalLength; 040 this.cacheData = cacheData; 041 } 042 043 /** 044 * Return result data. 045 */ 046 public List<T> getData() { 047 return data; 048 } 049 050 /** 051 * Return actual offset of the result. In most cases equals requested offset. 052 */ 053 public int getOffset() { 054 return offset; 055 } 056 057 /** 058 * Return total length of the data. 059 * <br/> 060 * <ul> 061 * <li>For non-paging requests equals size of the data.</li> 062 * <li>For paging requests should equals total number of records</li> 063 * </ul> 064 */ 065 public int getTotalLength() { 066 return totalLength; 067 } 068 069 /** 070 * Should we cache the data, retrieved, it is worth noting that not all 071 * {@link DataView} implementations will cache data. 072 * @return true by default. 073 */ 074 public boolean isCacheData() { 075 return cacheData; 076 } 077}