org.unitils.mock.argumentmatcher.impl
Class DefaultArgumentMatcher
java.lang.Object
org.unitils.mock.argumentmatcher.impl.DefaultArgumentMatcher
- All Implemented Interfaces:
- ArgumentMatcher
public class DefaultArgumentMatcher
- extends Object
- implements ArgumentMatcher
A matcher for checking whether an argument equals a given value. This matchers uses reference comparison if the
expected and actual arguments refer to the same object. Otherwise, lenient reflection comparison is used (This means
the actual order of collections will be ignored and only fields that have a non default value will be compared)
- Since:
- 15-dec-2008
- Author:
- Filip Neven, Tim Ducheyne
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultArgumentMatcher
public DefaultArgumentMatcher(Object value)
- Creates a matcher for the given value. The original value is stored and a copy of the value is taken so that it
can be compared even when the value itself was modified later-on.
- Parameters:
value
- The expected value
matches
public ArgumentMatcher.MatchResult matches(Object argument,
Object argumentAtInvocationTime)
- Returns true if the given object matches the expected argument, false otherwise. If the given argument refers to
the same object as the original value, true is returned. If the given argument is another object than the original
value, lenient reflection comparison is used to compare the values. This means that the actual order of collections
will be ignored and only fields that have a non default value will be compared.
- Specified by:
matches
in interface ArgumentMatcher
- Parameters:
argument
- The argument that was used by reference, not nullargumentAtInvocationTime
- Copy of the argument, taken at the time that the invocation was performed, not null
- Returns:
- The match result, not null
Copyright © 2011. All Rights Reserved.