1 3 package org.jmock.core; 4 5 import java.lang.reflect.Method ; 6 import java.util.Arrays ; 7 import java.util.Collections ; 8 import java.util.List ; 9 10 11 14 public class Invocation implements SelfDescribing 15 { 16 public final Object invokedObject; 17 public final Method invokedMethod; 18 public final List parameterValues; 19 20 public Invocation( Object invoked, Method method, Object [] parameterValues ) { 21 this.invokedObject = invoked; 22 this.invokedMethod = method; 23 this.parameterValues = parameterValues == null ? 24 Collections.EMPTY_LIST 25 : Collections.unmodifiableList(Arrays.asList(parameterValues)); 26 } 27 28 public String toString() { 29 return describeTo(new StringBuffer ()).toString(); 30 } 31 32 public boolean equals( Object other ) { 33 return (other instanceof Invocation) && this.equals((Invocation)other); 34 } 35 36 public boolean equals( Invocation other ) { 37 return other != null 38 && invokedObject == other.invokedObject 39 && invokedMethod.equals(other.invokedMethod) 40 && parameterValues.equals(other.parameterValues); 41 } 42 43 public int hashCode() { 44 return invokedObject.hashCode() ^ 45 invokedMethod.hashCode() ^ 46 parameterValues.hashCode(); 47 } 48 49 public StringBuffer describeTo( StringBuffer buffer ) { 50 buffer.append(invokedMethod.getDeclaringClass().getName()); 51 buffer.append("."); 52 buffer.append(invokedMethod.getName()); 53 Formatting.join(parameterValues, buffer, "(", ")"); 54 return buffer; 55 } 56 } 57 | Popular Tags |