Source code: com/mockobjects/constraint/And.java
1 /* Copyright (c) 2002 B13media Ltd. All rights reserved.
2 *
3 * Created on February 10, 2002, 11:49 PM
4 */
5 package com.mockobjects.constraint;
6
7 /** Calculates the logical conjunction of two constraints.
8 * Evaluation is shortcut, so that the second constraint is not
9 * called if the first constraint returns <code>false</code>.
10 */
11 public class And
12 implements Constraint
13 {
14 Constraint _p1, _p2;
15
16 public And(Constraint p1, Constraint p2) {
17 _p1 = p1;
18 _p2 = p2;
19 }
20
21 public boolean eval( Object o ) {
22 return _p1.eval(o) && _p2.eval(o);
23 }
24
25 public String toString() {
26 return "(" + _p1 + " and " + _p2 + ")";
27 }
28 }