001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php 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 */ 016package org.kuali.rice.krad.uif.util; 017 018import org.apache.commons.lang.builder.EqualsBuilder; 019import org.apache.commons.lang.builder.HashCodeBuilder; 020 021/** 022 * Holds the information for sorting a table by a column. 023 * 024 * <ul> 025 * <li>column index</li> 026 * <li>direction</li> 027 * <li>sort type</li> 028 * </ul> 029 * 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032public class ColumnSort { 033 034 /** 035 * Sort direction, either ASCending or DESCending. 036 */ 037 public enum Direction { ASC, DESC }; 038 039 private final int columnIndex; 040 private final Direction direction; 041 private final String sortType; 042 043 /** 044 * Constructs a ColumnSort instance. 045 * 046 * @param columnIndex the index of the column to sort on 047 * @param direction the direction of the sort 048 * @param sortType the type of the sort -- see {@link org.kuali.rice.krad.uif.UifConstants.TableToolsValues}. 049 */ 050 public ColumnSort(int columnIndex, Direction direction, String sortType) { 051 this.columnIndex = columnIndex; 052 this.direction = direction; 053 this.sortType = sortType; 054 } 055 056 /** 057 * Get the column index. 058 * 059 * @return the column index 060 */ 061 public int getColumnIndex() { 062 return columnIndex; 063 } 064 065 /** 066 * Get the sort direction. 067 * 068 * @return the sort direction 069 */ 070 public Direction getDirection() { 071 return direction; 072 } 073 074 /** 075 * Get the sort type. 076 * 077 * @return the sort type 078 */ 079 public String getSortType() { 080 return sortType; 081 } 082 083 @Override 084 public boolean equals(Object o) { 085 if (this == o) { 086 return true; 087 } 088 if (o == null || getClass() != o.getClass()) { 089 return false; 090 } 091 092 return EqualsBuilder.reflectionEquals(this, o); 093 } 094 095 @Override 096 public int hashCode() { 097 return HashCodeBuilder.reflectionHashCode(this); 098 } 099}