1 /* 2 * Copyright 2018-2022 Medical Information Systems Research Group (https://medical.zcu.cz), 3 * Department of Computer Science and Engineering, University of West Bohemia. 4 * Address: Univerzitni 8, 306 14 Plzen, Czech Republic. 5 * 6 * Author Petr Vcelak (vcelak@kiv.zcu.cz). 7 * 8 * This file is part of MRECore project. 9 * 10 * MRECore is free software: you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation, either version 3 of the License. 13 * 14 * MRECore is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with MRECore. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 package cz.zcu.mre.data.datatable; 23 24 import java.util.LinkedHashMap; 25 import java.util.Map; 26 27 /** 28 * The Class DataTableQuerySortBy. 29 * 30 * @author Petr Vcelak (vcelak@kiv.zcu.cz) 31 */ 32 public class DataTableQuerySortBy { 33 34 /** 35 * The map of sorts. 36 */ 37 private Map<String, DataTableQuerySortOrder> mapOfSorts; 38 39 /** 40 * Instantiates a new sort by. 41 */ 42 public DataTableQuerySortBy() { 43 if (mapOfSorts == null) { 44 mapOfSorts = new LinkedHashMap<>(); 45 } 46 } 47 48 /** 49 * Gets the sort bys. 50 * 51 * @return the sortBys 52 */ 53 public Map<String, DataTableQuerySortOrder> getSortBys() { 54 return mapOfSorts; 55 } 56 57 /** 58 * Adds the sort. 59 * 60 * @param sortBy the sort by 61 */ 62 public void addSort(String sortBy) { 63 mapOfSorts.put(sortBy, DataTableQuerySortOrder.ASC); 64 } 65 66 /** 67 * Adds the sort. 68 * 69 * @param sortBy the sort by 70 * @param sortOrder the sort order 71 */ 72 public void addSort(String sortBy, DataTableQuerySortOrder sortOrder) { 73 mapOfSorts.put(sortBy, sortOrder); 74 } 75 76 @Override 77 public String toString() { 78 return "SortBy{" + "mapOfSorts=" + mapOfSorts + '}'; 79 } 80 81 }