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 gwt.material.design.client.data.SortContext;
023import gwt.material.design.client.data.component.CategoryComponent;
024
025import java.util.List;
026
027public class LoadConfig<T> {
028
029    private final int offset;
030    private final int limit;
031    private final SortContext<T> sortContext;
032    private final List<CategoryComponent> openCategories;
033
034    public LoadConfig(int offset, int limit, SortContext<T> sortContext, List<CategoryComponent> openCategories) {
035        this.offset = offset;
036        this.limit = limit;
037        this.sortContext = sortContext;
038        this.openCategories = openCategories;
039    }
040
041    /**
042     * Get load offset.
043     */
044    public int getOffset() {
045        return offset;
046    }
047
048    /**
049     * Get load limit. Set to "0" for no limit.
050     */
051    public int getLimit() {
052        return limit;
053    }
054
055    /**
056     * Get sorters to use when loading. Usually used for remote data sources.
057     * Return null if no sort context exists.
058     */
059    public SortContext<T> getSortContext() {
060        return sortContext;
061    }
062
063    /**
064     * Get categories to load.
065     * Return null if no categories exists.
066     * FIXME: CategoryComponent belongs to table package, need to make similar class in data package
067     */
068    public List<CategoryComponent> getOpenCategories() {
069        return openCategories;
070    }
071
072    @Override
073    public String toString() {
074        return "LoadConfig{" +
075                "offset=" + offset +
076                ", limit=" + limit +
077                ", sortContext=" + sortContext +
078                ", openCategories=" + openCategories +
079                '}';
080    }
081}