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