Package org.mockito.internal.matchers
Class Equals
java.lang.Object
org.mockito.internal.matchers.Equals
- All Implemented Interfaces:
Serializable,ArgumentMatcher<Object>,ContainsExtraTypeInfo
- Direct Known Subclasses:
ArrayEquals
public class Equals
extends Object
implements ArgumentMatcher<Object>, ContainsExtraTypeInfo, Serializable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal ObjectinthashCode()booleanInforms if this matcher accepts the given argument.toString()toStringWithType(String className) Class<?> type()The type of the argument this matcher matches.booleantypeMatches(Object target) Checks if target target has matching type.
-
Constructor Details
-
Equals
-
-
Method Details
-
matches
Description copied from interface:ArgumentMatcherInforms if this matcher accepts the given argument.The method should never assert if the argument doesn't match. It should only return false.
See the example in the top level javadoc for
ArgumentMatcher- Specified by:
matchesin interfaceArgumentMatcher<Object>- Parameters:
actual- the argument- Returns:
- true if this matcher accepts the given argument.
-
type
Description copied from interface:ArgumentMatcherThe type of the argument this matcher matches.This method is used to differentiate between a matcher used to match a raw vararg array parameter from a matcher used to match a single value passed as a vararg parameter.
Where the matcher:
- is at the parameter index of a vararg parameter
- is the last matcher passed
- this method returns a type assignable to the vararg parameter's raw type, i.e. its array type.
For example:
// Given vararg method with signature: int someVarargMethod(String... args); // The following will match invocations with any number of parameters, i.e. any number of elements in the raw array. mock.someVarargMethod(isA(String[].class)); // The following will match invocations with a single parameter, i.e. one string in the raw array. mock.someVarargMethod(isA(String.class)); // The following will match invocations with two parameters, i.e. two strings in the raw array mock.someVarargMethod(isA(String.class), isA(String.class));Only matcher implementations that can conceptually match a raw vararg parameter should override this method.
- Specified by:
typein interfaceArgumentMatcher<Object>- Returns:
- the type this matcher handles. The default value of
Voidmeans the type is not known.
-
toString
-
getWanted
- Specified by:
getWantedin interfaceContainsExtraTypeInfo- Returns:
- Returns the wanted argument
-
equals
-
hashCode
public int hashCode() -
toStringWithType
- Specified by:
toStringWithTypein interfaceContainsExtraTypeInfo- Parameters:
className- - name of the class to be printed in description Returns more verbose description of the object which include type information
-
typeMatches
Description copied from interface:ContainsExtraTypeInfoChecks if target target has matching type. If the type matches, there is no point in rendering result fromContainsExtraTypeInfo.toStringWithType(String)- Specified by:
typeMatchesin interfaceContainsExtraTypeInfo
-