org.unitils.mock.argumentmatcher.impl
Class LenEqArgumentMatcher

java.lang.Object
  extended by org.unitils.mock.argumentmatcher.impl.LenEqArgumentMatcher
All Implemented Interfaces:
ArgumentMatcher

public class LenEqArgumentMatcher
extends Object
implements ArgumentMatcher

A matcher for checking whether an argument equals a given value. Reflection is used to compare all fields of these values. The actual order of collections will be ignored and only fields that have a non default value will be compared.

Author:
Kenny Claes, Filip Neven, Tim Ducheyne

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.unitils.mock.argumentmatcher.ArgumentMatcher
ArgumentMatcher.MatchResult
 
Constructor Summary
LenEqArgumentMatcher(Object value)
          Creates a matcher for the given value.
 
Method Summary
 ArgumentMatcher.MatchResult matches(Object argument, Object argumentAtInvocationTime)
          Returns true if the given object matches the expected argument, false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LenEqArgumentMatcher

public LenEqArgumentMatcher(Object value)
Creates a matcher for the given value. 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
Method Detail

matches

public ArgumentMatcher.MatchResult matches(Object argument,
                                           Object argumentAtInvocationTime)
Returns true if the given object matches the expected argument, false otherwise. The argumentAtInvocationTime is a copy (deep clone) of the arguments at the time of the invocation. This way the original values can still be used later-on even when changes occur to the original values (pass-by-value vs pass-by-reference).

Specified by:
matches in interface ArgumentMatcher
Parameters:
argument - The argument that were used by reference, not null
argumentAtInvocationTime - 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.