mockit.internal.expectations.argumentMatching.CaptureMatcher Maven / Gradle / Ivy
/*
* Copyright (c) 2006 Rogério Liesenfeld
* This file is subject to the terms of the MIT license (see LICENSE.txt).
*/
package mockit.internal.expectations.argumentMatching;
import java.util.*;
import javax.annotation.*;
public final class CaptureMatcher implements ArgumentMatcher>
{
@Nonnull private final List valueHolder;
@Nullable private Class expectedType;
public CaptureMatcher(@Nonnull List valueHolder) { this.valueHolder = valueHolder; }
public void setExpectedType(@Nonnull Class expectedType) { this.expectedType = expectedType; }
@Override
public boolean same(@Nonnull CaptureMatcher other) { return false; }
@Override
public boolean matches(@Nullable Object argValue)
{
if (expectedType == null || expectedType.isInstance(argValue)) {
//noinspection unchecked
valueHolder.add((T) argValue);
}
return true;
}
@Override
public void writeMismatchPhrase(@Nonnull ArgumentMismatch argumentMismatch) {}
}