|
|
|
@ -1,21 +1,4 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
|
|
|
* Version 2.0 (the "License"); you may not use this file except
|
|
|
|
|
* in compliance with the License.
|
|
|
|
|
* you may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
|
* under the License.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2023, Entgra (pvt) Ltd. (https://entgra.io) All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
|
|
|
@ -35,32 +18,15 @@
|
|
|
|
|
|
|
|
|
|
package org.wso2.carbon.device.mgt.common;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class holds required parameters for a querying a sort by column in pagination.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public class SortColumn {
|
|
|
|
|
List<String> name = new ArrayList<>();
|
|
|
|
|
List<SortColumn.types> type = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SortColumn Constructor with sort field parameter and splitting string into columnName and sortType
|
|
|
|
|
*
|
|
|
|
|
* @param sort which is separated by a colon(:) and first will be the columnNane and the second will be type ASC or DESC
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public SortColumn(List<String> sort) {
|
|
|
|
|
for (String sortBy: sort) {
|
|
|
|
|
String[] sorting = sortBy.split(":");
|
|
|
|
|
name.add(sorting[0]);
|
|
|
|
|
type.add(sorting.length >= 2 && (sorting[1].equalsIgnoreCase("desc")) ? types.DESC : types.ASC);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String name;
|
|
|
|
|
SortColumn.types type;
|
|
|
|
|
|
|
|
|
|
private enum types {
|
|
|
|
|
public enum types {
|
|
|
|
|
ASC, DESC
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -68,25 +34,25 @@ public class SortColumn {
|
|
|
|
|
* ColumnName setter method
|
|
|
|
|
* @param name of the column
|
|
|
|
|
*/
|
|
|
|
|
public void setName(List<String> name) { this.name = name; }
|
|
|
|
|
public void setName(String name) { this.name = name; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get the name of the column
|
|
|
|
|
* @return name
|
|
|
|
|
*/
|
|
|
|
|
public List<String> getName() { return name; }
|
|
|
|
|
public String getName() { return name; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Column sort type
|
|
|
|
|
* @param type of sort as ASC or DESC
|
|
|
|
|
*/
|
|
|
|
|
public void setType(List<SortColumn.types> type) { this.type = type; }
|
|
|
|
|
public void setType(SortColumn.types type) { this.type = type; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get column sort type
|
|
|
|
|
* @return type of sort
|
|
|
|
|
*/
|
|
|
|
|
public List<SortColumn.types> getType() { return type; }
|
|
|
|
|
public SortColumn.types getType() { return type; }
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|