1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.directory.api.ldap.model.filter;
22
23
24 import java.util.List;
25
26
27
28
29
30
31
32 public class OrNode extends BranchNode
33 {
34
35
36
37
38
39 public OrNode( List<ExprNode> childList )
40 {
41 super( AssertionType.OR, childList );
42 }
43
44
45
46
47
48
49
50 public OrNode( ExprNode... childList )
51 {
52 super( AssertionType.OR, childList );
53 }
54
55
56
57
58
59 public OrNode()
60 {
61 super( AssertionType.OR );
62 }
63
64
65
66
67
68
69
70 public AssertionType getOperator()
71 {
72 return AssertionType.OR;
73 }
74
75
76
77
78
79
80
81 public boolean isDisjunction()
82 {
83 return true;
84 }
85
86
87
88
89
90
91
92 public boolean isConjunction()
93 {
94 return false;
95 }
96
97
98
99
100
101
102
103 public boolean isNegation()
104 {
105 return false;
106 }
107
108
109
110
111
112
113
114
115 public StringBuilder printRefinementToBuffer( StringBuilder buf )
116 {
117 buf.append( "or: {" );
118 boolean isFirst = true;
119
120 for ( ExprNode node : children )
121 {
122 if ( isFirst )
123 {
124 isFirst = false;
125 buf.append( ' ' );
126 }
127 else
128 {
129 buf.append( ", " );
130 }
131
132 node.printRefinementToBuffer( buf );
133 }
134
135 buf.append( " }" );
136
137 return buf;
138 }
139
140
141
142
143
144
145
146
147
148 public String toString()
149 {
150 StringBuilder buf = new StringBuilder();
151 buf.append( "(|" );
152
153 buf.append( super.toString() );
154
155 for ( ExprNode child : getChildren() )
156 {
157 buf.append( child );
158 }
159
160 buf.append( ')' );
161
162 return buf.toString();
163 }
164
165
166
167
168
169
170 public int hashCode()
171 {
172 int hash = 37;
173 hash = hash * 17 + AssertionType.OR.hashCode();
174 hash = hash * 17 + ( annotations == null ? 0 : annotations.hashCode() );
175 return hash;
176 }
177
178
179
180
181
182 public boolean equals( Object other )
183 {
184 if ( this == other )
185 {
186 return true;
187 }
188
189 if ( !( other instanceof OrNode ) )
190 {
191 return false;
192 }
193
194 OrNode otherExprNode = ( OrNode ) other;
195
196 List<ExprNode> otherChildren = otherExprNode.getChildren();
197
198 if ( otherChildren == children )
199 {
200 return true;
201 }
202
203 if ( children.size() != otherChildren.size() )
204 {
205 return false;
206 }
207
208 for ( int i = 0; i < children.size(); i++ )
209 {
210 ExprNode child = children.get( i );
211 ExprNode otherChild = otherChildren.get( i );
212
213 if ( !child.equals( otherChild ) )
214 {
215 return false;
216 }
217 }
218
219 return true;
220 }
221 }