Package org.mockito.internal.invocation
Class TypeSafeMatching
- java.lang.Object
-
- org.mockito.internal.invocation.TypeSafeMatching
-
- All Implemented Interfaces:
ArgumentMatcherAction
public class TypeSafeMatching extends java.lang.Object implements ArgumentMatcherAction
-
-
Field Summary
Fields Modifier and Type Field Description private static ArgumentMatcherAction
TYPE_SAFE_MATCHING_ACTION
-
Constructor Summary
Constructors Modifier Constructor Description private
TypeSafeMatching()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
apply(ArgumentMatcher matcher, java.lang.Object argument)
Implementations must apply the given matcher to the argument and returntrue
if the operation was successful orfalse
if not.private static java.lang.Class<?>
getArgumentType(ArgumentMatcher<?> argumentMatcher)
Returns the type ofArgumentMatcher.matches(Object)
of the givenArgumentMatcher
implementation.private static boolean
isCompatible(ArgumentMatcher<?> argumentMatcher, java.lang.Object argument)
Returnstrue
if the given argument can be passed to the givenargumentMatcher
without causing aClassCastException
.private static boolean
isMatchesMethod(java.lang.reflect.Method method)
Returnstrue
if the given method isArgumentMatcher.matches(Object)
static ArgumentMatcherAction
matchesTypeSafe()
-
-
-
Field Detail
-
TYPE_SAFE_MATCHING_ACTION
private static final ArgumentMatcherAction TYPE_SAFE_MATCHING_ACTION
-
-
Method Detail
-
matchesTypeSafe
public static ArgumentMatcherAction matchesTypeSafe()
-
apply
public boolean apply(ArgumentMatcher matcher, java.lang.Object argument)
Description copied from interface:ArgumentMatcherAction
Implementations must apply the given matcher to the argument and returntrue
if the operation was successful orfalse
if not. In this case no more matchers and arguments will be passed byMatcherApplicationStrategy.forEachMatcherAndArgument(ArgumentMatcherAction)
to this method. .- Specified by:
apply
in interfaceArgumentMatcherAction
- Parameters:
matcher
- to process the argument, nevernull
argument
- to be processed by the matcher, can benull
- Returns:
true
if the matcher was successfully applied to the argument and the next pair of matcher and argument should be passedfalse
otherwise
-
isCompatible
private static boolean isCompatible(ArgumentMatcher<?> argumentMatcher, java.lang.Object argument)
Returnstrue
if the given argument can be passed to the givenargumentMatcher
without causing aClassCastException
.
-
getArgumentType
private static java.lang.Class<?> getArgumentType(ArgumentMatcher<?> argumentMatcher)
Returns the type ofArgumentMatcher.matches(Object)
of the givenArgumentMatcher
implementation.
-
isMatchesMethod
private static boolean isMatchesMethod(java.lang.reflect.Method method)
Returnstrue
if the given method isArgumentMatcher.matches(Object)
-
-