View Javadoc
1 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */ 2 package org.jmock.matcher; 3 4 import org.jmock.Constraint; 5 import org.jmock.dynamic.Invocation; 6 7 import java.util.List; 8 9 public class ArgumentsMatcher 10 extends StatelessInvocationMatcher { 11 private Constraint[] constraints; 12 13 public ArgumentsMatcher(Constraint[] constraints) { 14 ArgumentsMatcher.this.constraints = constraints; 15 } 16 17 public boolean matches(Invocation invocation) { 18 return constraints.length == invocation.getParameterValues().size() 19 && matchesValues(invocation.getParameterValues()); 20 } 21 22 private boolean matchesValues(List list) { 23 for (int i = 0; i < constraints.length; ++i) { 24 if (!constraints[i].eval(list.get(i))) { 25 return false; 26 } 27 } 28 return true; 29 } 30 31 public Constraint[] getConstraints() { 32 return constraints; 33 } 34 35 public String toString() { 36 StringBuffer result = new StringBuffer(); 37 result.append("ArgumentMatcher: "); 38 for (int i = 0; i < constraints.length; ++i) { 39 result.append(constraints[i]).append(", "); 40 } 41 return result.toString(); 42 } 43 44 public boolean equals(Object other) { 45 return other != null && toString().equals(other.toString()); 46 } 47 }

This page was automatically generated by Maven