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 AndNode extends BranchNode
33 {
34
35
36
37
38
39 public AndNode( List<ExprNode> childList )
40 {
41 super( AssertionType.AND, childList );
42 }
43
44
45
46
47
48
49
50 public AndNode( ExprNode... childList )
51 {
52 super( AssertionType.AND, childList );
53 }
54
55
56
57
58
59 public AndNode()
60 {
61 super( AssertionType.AND );
62 }
63
64
65
66
67
68
69
70 public AssertionType getOperator()
71 {
72 return AssertionType.AND;
73 }
74
75
76
77
78
79
80
81 public boolean isDisjunction()
82 {
83 return false;
84 }
85
86
87
88
89
90
91
92 public boolean isConjunction()
93 {
94 return true;
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
116 @Override
117 public StringBuilder printRefinementToBuffer( StringBuilder buf )
118 {
119 buf.append( "and: {" );
120 boolean isFirst = true;
121
122 for ( ExprNode node : children )
123 {
124 if ( isFirst )
125 {
126 isFirst = false;
127 buf.append( ' ' );
128 }
129 else
130 {
131 buf.append( ", " );
132 }
133
134 node.printRefinementToBuffer( buf );
135 }
136
137 buf.append( " }" );
138
139 return buf;
140 }
141
142
143
144
145
146
147
148
149
150 @Override
151 public String toString()
152 {
153 StringBuilder buf = new StringBuilder();
154 buf.append( "(&" );
155
156 buf.append( super.toString() );
157
158 for ( ExprNode child : getChildren() )
159 {
160 buf.append( child );
161 }
162
163 buf.append( ')' );
164
165 return buf.toString();
166 }
167
168
169
170
171
172
173 @Override
174 public int hashCode()
175 {
176 int hash = 37;
177 hash = hash * 17 + AssertionType.AND.hashCode();
178 hash = hash * 17 + ( annotations == null ? 0 : annotations.hashCode() );
179 return hash;
180 }
181
182
183
184
185
186 @Override
187 public boolean equals( Object other )
188 {
189 if ( this == other )
190 {
191 return true;
192 }
193
194 if ( !( other instanceof AndNode ) )
195 {
196 return false;
197 }
198
199 AndNode otherExprNode = ( AndNode ) other;
200
201 List<ExprNode> otherChildren = otherExprNode.getChildren();
202
203 if ( otherChildren == children )
204 {
205 return true;
206 }
207
208 if ( children.size() != otherChildren.size() )
209 {
210 return false;
211 }
212
213 for ( int i = 0; i < children.size(); i++ )
214 {
215 ExprNode child = children.get( i );
216 ExprNode otherChild = otherChildren.get( i );
217
218 if ( !child.equals( otherChild ) )
219 {
220 return false;
221 }
222 }
223
224 return true;
225 }
226 }