1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.persistence.api.dao.search;
20
21 import java.io.Serializable;
22 import java.util.Optional;
23 import org.apache.commons.lang3.builder.EqualsBuilder;
24 import org.apache.commons.lang3.builder.HashCodeBuilder;
25 import org.apache.commons.lang3.builder.ToStringBuilder;
26
27 public class OrderByClause implements Serializable {
28
29 private static final long serialVersionUID = -1741826744085524716L;
30
31 public enum Direction {
32
33 ASC,
34 DESC
35
36 }
37
38 private String field;
39
40 private Direction direction;
41
42 public String getField() {
43 return field;
44 }
45
46 public void setField(final String field) {
47 this.field = field;
48 }
49
50 public Direction getDirection() {
51 return Optional.ofNullable(direction).orElse(Direction.ASC);
52 }
53
54 public void setDirection(final Direction direction) {
55 this.direction = direction;
56 }
57
58 @Override
59 public int hashCode() {
60 return new HashCodeBuilder().
61 append(field).
62 append(direction).
63 build();
64 }
65
66 @Override
67 public boolean equals(final Object obj) {
68 if (this == obj) {
69 return true;
70 }
71 if (obj == null) {
72 return false;
73 }
74 if (getClass() != obj.getClass()) {
75 return false;
76 }
77 final OrderByClause other = (OrderByClause) obj;
78 return new EqualsBuilder().
79 append(field, other.field).
80 append(direction, other.direction).
81 build();
82 }
83
84 @Override
85 public String toString() {
86 return new ToStringBuilder(this).
87 append(field).
88 append(direction).
89 build();
90 }
91 }