1 3 package org.jmock.core.matcher; 4 5 import org.jmock.core.Constraint; 6 import org.jmock.core.Invocation; 7 8 9 public class MethodNameMatcher 10 extends StatelessInvocationMatcher 11 { 12 private Constraint constraint; 13 14 public MethodNameMatcher( Constraint constraint ) { 15 this.constraint = constraint; 16 } 17 18 public MethodNameMatcher( final String methodName ) { 19 this(new Constraint() 20 { 21 public boolean eval( Object o ) { 22 return methodName.equals(o); 23 } 24 25 public StringBuffer describeTo( StringBuffer buffer ) { 26 return buffer.append(methodName); 27 } 28 }); 29 } 30 31 public boolean matches( Invocation invocation ) { 32 return constraint.eval(invocation.invokedMethod.getName()); 33 } 34 35 public StringBuffer describeTo( StringBuffer buffer ) { 36 return constraint.describeTo(buffer); 37 } 38 } 39 | Popular Tags |