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