mockit.internal.expectations.invocation.ArgumentValuesAndMatchers Maven / Gradle / Ivy
/*
* Copyright (c) 2006 JMockit developers
* This file is subject to the terms of the MIT license (see LICENSE.txt).
*/
package mockit.internal.expectations.invocation;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.util.List;
import java.util.Map;
import mockit.internal.expectations.argumentMatching.AlwaysTrueMatcher;
import mockit.internal.expectations.argumentMatching.ArgumentMatcher;
import mockit.internal.expectations.argumentMatching.ArgumentMismatch;
import mockit.internal.expectations.argumentMatching.EqualityMatcher;
import mockit.internal.expectations.argumentMatching.HamcrestAdapter;
import mockit.internal.expectations.argumentMatching.ReflectiveMatcher;
import org.checkerframework.checker.index.qual.NonNegative;
abstract class ArgumentValuesAndMatchers {
@NonNull
final InvocationArguments signature;
@NonNull
Object[] values;
@Nullable
List> matchers;
ArgumentValuesAndMatchers(@NonNull InvocationArguments signature, @NonNull Object[] values) {
this.signature = signature;
this.values = values;
}
final void setValuesWithNoMatchers(@NonNull Object[] argsToVerify) {
setValuesAndMatchers(argsToVerify, null);
}
@NonNull
final Object[] prepareForVerification(@NonNull Object[] argsToVerify,
@Nullable List> matchersToUse) {
Object[] replayArgs = values;
setValuesAndMatchers(argsToVerify, matchersToUse);
return replayArgs;
}
final void setValuesAndMatchers(@NonNull Object[] argsToVerify, @Nullable List> matchersToUse) {
values = argsToVerify;
matchers = matchersToUse;
}
@Nullable
final ArgumentMatcher> getArgumentMatcher(@NonNegative int parameterIndex) {
if (matchers == null) {
return null;
}
ArgumentMatcher> matcher = parameterIndex < matchers.size() ? matchers.get(parameterIndex) : null;
if (matcher == null && parameterIndex < values.length && values[parameterIndex] == null) {
matcher = AlwaysTrueMatcher.ANY_VALUE;
}
return matcher;
}
abstract boolean isMatch(@NonNull Object[] replayArgs, @NonNull Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy