org.easymock

Class AbstractMatcher

Implemented Interfaces:
ArgumentsMatcher

public abstract class AbstractMatcher
extends java.lang.Object
implements ArgumentsMatcher

A convenience implementation of ArgumentsMatcher. A subclass that does not redefine any method will behave like MockControl.EQUALS_MATCHER.

Method Summary

protected boolean
argumentMatches(Object expected, Object actual)
Checks whether an expected argument matches an actual argument; the method is used by AbstractMatcher.matches(Object[], Object[]).
protected String
argumentToString(Object argument)
Converts an argument to a String, used by AbstractMatcher.toString(Object[]).
boolean
matches(Object[] expected, Object[] actual)
Checks whether an expected argument array matches an actual argument array.
String
toString(Object[] arguments)
Returns a string representation of the matcher.

Method Details

argumentMatches

protected boolean argumentMatches(Object expected,
                                  Object actual)
Checks whether an expected argument matches an actual argument; the method is used by AbstractMatcher.matches(Object[], Object[]). The arguments provided to this method are always not null.
Parameters:
expected - the expected argument.
actual - the actual argument.
Returns:
true if the arguments match, false otherwise.

argumentToString

protected String argumentToString(Object argument)
Converts an argument to a String, used by AbstractMatcher.toString(Object[]).
Parameters:
argument - the argument to convert to a String.
Returns:
a String representation of the argument.

matches

public boolean matches(Object[] expected,
                       Object[] actual)
Checks whether an expected argument array matches an actual argument array. This convenience implementation uses argumentMatches(Object, Object) to check whether arguments pairs match. If all the arguments match, true is returned, otherwise false. In two cases, argumentMatches(Object, Object) is not called: If both argument arrays are null, they match; if one and only one is null, they do not match.
Parameters:
expected - the expected arguments.
actual - the actual arguments.
Returns:
true if the arguments match, false otherwise.

toString

public String toString(Object[] arguments)
Returns a string representation of the matcher. This convenience implementation calls AbstractMatcher.argumentToString(Object) for every argument in the given array and returns the string representations of the arguments separated by commas.
Parameters:
arguments - the arguments to be used in the string representation.
Returns:
a string representation of the matcher.