Package org.mockito.internal.invocation
Class MatcherApplicationStrategy
- java.lang.Object
-
- org.mockito.internal.invocation.MatcherApplicationStrategy
-
public class MatcherApplicationStrategy extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
MatcherApplicationStrategy.MatcherApplicationType
-
Field Summary
Fields Modifier and Type Field Description private Invocation
invocation
private java.util.List<ArgumentMatcher<?>>
matchers
private MatcherApplicationStrategy.MatcherApplicationType
matchingType
-
Constructor Summary
Constructors Modifier Constructor Description private
MatcherApplicationStrategy(Invocation invocation, java.util.List<ArgumentMatcher<?>> matchers, MatcherApplicationStrategy.MatcherApplicationType matchingType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.List<ArgumentMatcher<?>>
appendLastMatcherNTimes(java.util.List<ArgumentMatcher<?>> matchers, int timesToAppendLastMatcher)
boolean
forEachMatcherAndArgument(ArgumentMatcherAction action)
Applies the givenArgumentMatcherAction
to all arguments and corresponding matchersstatic MatcherApplicationStrategy
getMatcherApplicationStrategyFor(Invocation invocation, java.util.List<ArgumentMatcher<?>> matchers)
Returns theMatcherApplicationStrategy
that must be used to capture the arguments of the given invocation using the given matchers.private static MatcherApplicationStrategy.MatcherApplicationType
getMatcherApplicationType(Invocation invocation, java.util.List<ArgumentMatcher<?>> matchers)
private static boolean
isLastMatcherVarargMatcher(java.util.List<ArgumentMatcher<?>> matchers)
private static ArgumentMatcher<?>
lastMatcher(java.util.List<ArgumentMatcher<?>> matchers)
private static int
varargLength(Invocation invocation)
-
-
-
Field Detail
-
invocation
private final Invocation invocation
-
matchers
private final java.util.List<ArgumentMatcher<?>> matchers
-
matchingType
private final MatcherApplicationStrategy.MatcherApplicationType matchingType
-
-
Constructor Detail
-
MatcherApplicationStrategy
private MatcherApplicationStrategy(Invocation invocation, java.util.List<ArgumentMatcher<?>> matchers, MatcherApplicationStrategy.MatcherApplicationType matchingType)
-
-
Method Detail
-
getMatcherApplicationStrategyFor
public static MatcherApplicationStrategy getMatcherApplicationStrategyFor(Invocation invocation, java.util.List<ArgumentMatcher<?>> matchers)
Returns theMatcherApplicationStrategy
that must be used to capture the arguments of the given invocation using the given matchers.- Parameters:
invocation
- that contain the arguments to capturematchers
- that will be used to capture the arguments of the invocation, the passedList
is not required to contain aCapturingMatcher
- Returns:
- never
null
-
forEachMatcherAndArgument
public boolean forEachMatcherAndArgument(ArgumentMatcherAction action)
Applies the givenArgumentMatcherAction
to all arguments and corresponding matchers- Parameters:
action
- must not benull
- Returns:
true
if the given action returnedtrue
for all arguments and matchers passed to it.false
if the given action returnedfalse
for one of the passed arguments and matchersfalse
if the given matchers don't fit to the given invocation because too many or to few matchers are available.
-
getMatcherApplicationType
private static MatcherApplicationStrategy.MatcherApplicationType getMatcherApplicationType(Invocation invocation, java.util.List<ArgumentMatcher<?>> matchers)
-
isLastMatcherVarargMatcher
private static boolean isLastMatcherVarargMatcher(java.util.List<ArgumentMatcher<?>> matchers)
-
appendLastMatcherNTimes
private static java.util.List<ArgumentMatcher<?>> appendLastMatcherNTimes(java.util.List<ArgumentMatcher<?>> matchers, int timesToAppendLastMatcher)
-
varargLength
private static int varargLength(Invocation invocation)
-
lastMatcher
private static ArgumentMatcher<?> lastMatcher(java.util.List<ArgumentMatcher<?>> matchers)
-
-