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 java.util.concurrent.ConcurrentMap<java.lang.Class<?>,java.lang.Class<?>>argumentTypeCacheThis cache is in theory unbounded.private static ArgumentMatcherActionTYPE_SAFE_MATCHING_ACTION
-
Constructor Summary
Constructors Modifier Constructor Description privateTypeSafeMatching()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(ArgumentMatcher matcher, java.lang.Object argument)Implementations must apply the given matcher to the argument and returntrueif the operation was successful orfalseif not.private static java.lang.Class<?>getArgumentType(ArgumentMatcher<?> matcher)private static java.lang.Class<?>getArgumentTypeUncached(ArgumentMatcher<?> argumentMatcher)Returns the type ofArgumentMatcher.matches(Object)of the givenArgumentMatcherimplementation.private static booleanisCompatible(ArgumentMatcher<?> argumentMatcher, java.lang.Object argument)Returnstrueif the given argument can be passed to the givenargumentMatcherwithout causing aClassCastException.private static booleanisMatchesMethod(java.lang.reflect.Method method)Returnstrueif the given method isArgumentMatcher.matches(Object)static ArgumentMatcherActionmatchesTypeSafe()
-
-
-
Field Detail
-
TYPE_SAFE_MATCHING_ACTION
private static final ArgumentMatcherAction TYPE_SAFE_MATCHING_ACTION
-
argumentTypeCache
private static final java.util.concurrent.ConcurrentMap<java.lang.Class<?>,java.lang.Class<?>> 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 (<200) in all but the most contrived cases, and form a small percentage of the overall memory usage of those classes.
-
-
Method Detail
-
matchesTypeSafe
public static ArgumentMatcherAction matchesTypeSafe()
-
apply
public boolean apply(ArgumentMatcher matcher, java.lang.Object argument)
Description copied from interface:ArgumentMatcherActionImplementations must apply the given matcher to the argument and returntrueif the operation was successful orfalseif not. In this case no more matchers and arguments will be passed byMatcherApplicationStrategy.forEachMatcherAndArgument(ArgumentMatcherAction)to this method. .- Specified by:
applyin interfaceArgumentMatcherAction- Parameters:
matcher- to process the argument, nevernullargument- to be processed by the matcher, can benull- Returns:
trueif the matcher was successfully applied to the argument and the next pair of matcher and argument should be passedfalseotherwise
-
isCompatible
private static boolean isCompatible(ArgumentMatcher<?> argumentMatcher, java.lang.Object argument)
Returnstrueif the given argument can be passed to the givenargumentMatcherwithout causing aClassCastException.
-
getArgumentType
private static java.lang.Class<?> getArgumentType(ArgumentMatcher<?> matcher)
-
getArgumentTypeUncached
private static java.lang.Class<?> getArgumentTypeUncached(ArgumentMatcher<?> argumentMatcher)
Returns the type ofArgumentMatcher.matches(Object)of the givenArgumentMatcherimplementation.
-
isMatchesMethod
private static boolean isMatchesMethod(java.lang.reflect.Method method)
Returnstrueif the given method isArgumentMatcher.matches(Object)
-
-