KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > dynamic > FullConstraintMatcher


1 /*
2  * Created on 20-Apr-03
3  */

4 package com.mockobjects.dynamic;
5
6 import com.mockobjects.constraint.Constraint;
7
8
9 public class FullConstraintMatcher implements ConstraintMatcher {
10
11     private Constraint[] constraints;
12
13     public FullConstraintMatcher(Constraint[] constraints) {
14         this.constraints = constraints;
15     }
16     
17     public FullConstraintMatcher(Constraint c1) {
18         this(new Constraint[] {c1});
19     }
20     
21     public FullConstraintMatcher(Constraint c1, Constraint c2) {
22         this(new Constraint[] {c1, c2});
23     }
24     
25     public FullConstraintMatcher(Constraint c1, Constraint c2, Constraint c3) {
26         this(new Constraint[] {c1, c2, c3});
27     }
28     
29     public boolean matches(Object JavaDoc[] args) {
30
31         if( args.length != constraints.length ) return false;
32         
33         for (int i = 0; i < args.length; i++) {
34             if( !constraints[i].eval(args[i]) ) return false;
35         }
36         return true;
37     }
38     
39     public Object JavaDoc[] getConstraints() {
40         return constraints;
41     }
42     
43 }
44
Popular Tags