1 package org.nuiton.util.pagination;
2
3 /*
4 * #%L
5 * Nuiton Utils
6 * %%
7 * Copyright (C) 2004 - 2014 CodeLutin
8 * %%
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program 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 Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU General Lesser Public
20 * License along with this program. If not, see
21 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22 * #L%
23 */
24
25 import java.io.Serializable;
26
27 /**
28 * This class represents an 'order' information : order clause and asc/desc
29 *
30 * @author Arnaud Thimel (Code Lutin)
31 * @since 3.0
32 */
33 public class PaginationOrder implements Serializable {
34
35 private static final long serialVersionUID = 1L;
36
37 protected String clause;
38 protected boolean desc;
39
40 public PaginationOrder(String clause, boolean desc) {
41 this.clause = clause;
42 this.desc = desc;
43 }
44
45 public String getClause() {
46 return clause;
47 }
48
49 public void setClause(String clause) {
50 this.clause = clause;
51 }
52
53 public boolean isDesc() {
54 return desc;
55 }
56
57 public void setDesc(boolean desc) {
58 this.desc = desc;
59 }
60
61 @Override
62 public boolean equals(Object o) {
63 if (this == o) {
64 return true;
65 }
66 if (o == null || getClass() != o.getClass()) {
67 return false;
68 }
69
70 PaginationOrder that = (PaginationOrder) o;
71
72 if (desc != that.desc) {
73 return false;
74 }
75 boolean result = clause != null ? clause.equals(that.clause) : that.clause == null;
76 return result;
77
78 }
79
80 @Override
81 public int hashCode() {
82 int result = clause != null ? clause.hashCode() : 0;
83 result = 31 * result + (desc ? 1 : 0);
84 return result;
85 }
86
87 }