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 org.apache.commons.lang3.builder.EqualsBuilder;
22 import org.apache.commons.lang3.builder.HashCodeBuilder;
23 import org.apache.commons.lang3.builder.ToStringBuilder;
24
25
26
27
28 public class AttrCond extends AbstractSearchCond {
29
30 private static final long serialVersionUID = 3275277728404021417L;
31
32 public enum Type {
33
34 LIKE,
35 ILIKE,
36 EQ,
37 IEQ,
38 GT,
39 LT,
40 GE,
41 LE,
42 ISNULL,
43 ISNOTNULL
44
45 }
46
47 private Type type;
48
49 private String schema;
50
51 private String expression;
52
53 public AttrCond() {
54 super();
55 }
56
57 public AttrCond(final Type conditionType) {
58 super();
59 this.type = conditionType;
60 }
61
62 public final String getExpression() {
63 return expression;
64 }
65
66 public final void setExpression(final String conditionExpression) {
67 this.expression = conditionExpression;
68 }
69
70 public final String getSchema() {
71 return schema;
72 }
73
74 public final void setSchema(final String conditionSchema) {
75 this.schema = conditionSchema;
76 }
77
78 public final Type getType() {
79 return type;
80 }
81
82 public final void setType(final Type conditionType) {
83 this.type = conditionType;
84 }
85
86 @Override
87 public final boolean isValid() {
88 return type != null && schema != null && (type == Type.ISNULL || type == Type.ISNOTNULL || expression != null);
89 }
90
91 @Override
92 public int hashCode() {
93 return new HashCodeBuilder().
94 append(type).
95 append(schema).
96 append(expression).
97 build();
98 }
99
100 @Override
101 public boolean equals(final Object obj) {
102 if (this == obj) {
103 return true;
104 }
105 if (obj == null) {
106 return false;
107 }
108 if (getClass() != obj.getClass()) {
109 return false;
110 }
111 final AttrCond other = (AttrCond) obj;
112 return new EqualsBuilder().
113 append(type, other.type).
114 append(schema, other.schema).
115 append(expression, other.expression).
116 build();
117 }
118
119 @Override
120 public String toString() {
121 return new ToStringBuilder(this).
122 append(type).
123 append(schema).
124 append(expression).
125 build();
126 }
127 }