View Javadoc
1   /*
2    * Copyright (c) 2006 JMockit developers
3    * This file is subject to the terms of the MIT license (see LICENSE.txt).
4    */
5   package mockit.internal.expectations;
6   
7   import edu.umd.cs.findbugs.annotations.NonNull;
8   import edu.umd.cs.findbugs.annotations.Nullable;
9   
10  import java.util.List;
11  
12  import mockit.internal.expectations.argumentMatching.ArgumentMatcher;
13  
14  import org.checkerframework.checker.index.qual.NonNegative;
15  
16  final class VerifiedExpectation {
17      @NonNull
18      final Expectation expectation;
19      @NonNull
20      final Object[] arguments;
21      @Nullable
22      final List<ArgumentMatcher<?>> argMatchers;
23      private final int replayIndex;
24  
25      VerifiedExpectation(@NonNull Expectation expectation, @NonNull Object[] arguments,
26              @Nullable List<ArgumentMatcher<?>> argMatchers, int replayIndex) {
27          this.expectation = expectation;
28          this.arguments = arguments;
29          this.argMatchers = argMatchers;
30          this.replayIndex = replayIndex;
31      }
32  
33      boolean matchesReplayIndex(@NonNegative int expectationIndex) {
34          return replayIndex < 0 || replayIndex == expectationIndex;
35      }
36  
37      @Nullable
38      Object captureNewInstance() {
39          return expectation.invocation.instance;
40      }
41  }