01: /*
02: * $Id: SortParam.java 458264 2005-12-08 07:50:37Z ivaynberg $
03: * $Revision: 458264 $
04: * $Date: 2005-12-08 08:50:37 +0100 (Thu, 08 Dec 2005) $
05: *
06: * ====================================================================
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19: package wicket.extensions.markup.html.repeater.util;
20:
21: import java.io.Serializable;
22:
23: /**
24: * Represents sorting information of a property
25: *
26: * @author Igor Vaynberg ( ivaynberg )
27: */
28: public class SortParam implements Serializable {
29: private static final long serialVersionUID = 1L;
30:
31: private String property;
32: private boolean asc;
33:
34: /**
35: * @param property
36: * sort property
37: * @param asc
38: * sort direction
39: */
40: public SortParam(String property, boolean asc) {
41: this .property = property;
42: this .asc = asc;
43: }
44:
45: /**
46: * @return true if sort dir is ascending, false otherwise
47: */
48: public boolean isAscending() {
49: return asc;
50: }
51:
52: /**
53: * @return sort property
54: */
55: public String getProperty() {
56: return property;
57: }
58:
59: /**
60: * @see java.lang.Object#equals(java.lang.Object)
61: */
62: public boolean equals(Object rhs) {
63: if (rhs instanceof SortParam) {
64: SortParam param = (SortParam) rhs;
65: return getProperty().equals(param.getProperty())
66: && isAscending() == param.isAscending();
67: }
68: return false;
69: }
70:
71: /**
72: * @see java.lang.Object#toString()
73: */
74: public String toString() {
75: return new StringBuffer().append("[SortParam property=")
76: .append(getProperty()).append(" ascending=")
77: .append(asc).append("]").toString();
78: }
79: }
|