1 /**
2 * Copyright 2011-2013 The Kuali Foundation Licensed under the
3 * Educational Community License, Version 2.0 (the "License"); you may
4 * not use this file except in compliance with the License. You may
5 * obtain a copy of the License at
6 *
7 * http://www.osedu.org/licenses/ECL-2.0
8 *
9 * Unless required by applicable law or agreed to in writing,
10 * software distributed under the License is distributed on an "AS IS"
11 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 * or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 package org.kuali.mobility.security.authz.expression;
17
18 import org.kuali.mobility.security.user.api.User;
19
20 /**
21 * An Expression that does AND logic on one or more expressions.
22 */
23 public class AndExpression extends AbstractNonLeafExpression {
24
25 private static final long serialVersionUID = -7257967361622679088L;
26
27 /**
28 * Creates a new instance of a <code>AndExpression</code>
29 */
30 public AndExpression() {
31 super();
32 }
33
34 /**
35 * Evaluates the expression against the user
36 * @param user User to test the expression against.
37 * @return True if the expression is true
38 */
39 public boolean evaluate(User user) {
40 for (Expression child : getChildren()) {
41 if (!child.evaluate(user)) {
42 return false;
43 }
44 }
45 return true;
46 }
47
48 @Override
49 public boolean equals(Object obj) {
50 if (obj instanceof AndExpression) {
51 AndExpression other = (AndExpression)obj;
52 return getChildren().equals(other.getChildren());
53 }
54 return false;
55 }
56
57
58 }