Package org.mockito.internal.invocation
Class TypeSafeMatching
java.lang.Object
org.mockito.internal.invocation.TypeSafeMatching
- All Implemented Interfaces:
ArgumentMatcherAction
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ConcurrentMap
<Class<?>, Class<?>> This cache is in theory unbounded.private static final ArgumentMatcherAction
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
apply
(ArgumentMatcher matcher, Object argument) Implementations must apply the given matcher to the argument and returntrue
if the operation was successful orfalse
if not.private static Class
<?> getArgumentType
(ArgumentMatcher<?> matcher) private static Class
<?> getArgumentTypeUncached
(ArgumentMatcher<?> argumentMatcher) Returns the type ofArgumentMatcher.matches(Object)
of the givenArgumentMatcher
implementation.private static boolean
isCompatible
(ArgumentMatcher<?> argumentMatcher, Object argument) Returnstrue
if the given argument can be passed to the givenargumentMatcher
without causing aClassCastException
.private static boolean
isMatchesMethod
(Method method) Returnstrue
if the given method isArgumentMatcher.matches(Object)
static ArgumentMatcherAction
-
Field Details
-
TYPE_SAFE_MATCHING_ACTION
-
argumentTypeCache
This cache is in theory unbounded. However, its max size is bounded by the number of types of argument matchers that are both in the system and being used, which is expected to bound the cache's size to a low number (invalid input: '<'200) in all but the most contrived cases, and form a small percentage of the overall memory usage of those classes.
-
-
Constructor Details
-
TypeSafeMatching
private TypeSafeMatching()
-
-
Method Details
-
matchesTypeSafe
-
apply
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
Returnstrue
if the given argument can be passed to the givenargumentMatcher
without causing aClassCastException
. -
getArgumentType
-
getArgumentTypeUncached
Returns the type ofArgumentMatcher.matches(Object)
of the givenArgumentMatcher
implementation. -
isMatchesMethod
Returnstrue
if the given method isArgumentMatcher.matches(Object)
-