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.mocking;
7   
8   import edu.umd.cs.findbugs.annotations.NonNull;
9   
10  import java.lang.reflect.Field;
11  import java.util.Collection;
12  import java.util.List;
13  
14  final class CaptureOfNewInstancesForFields extends CaptureOfNewInstances {
15      void resetCaptureCount(@NonNull Field mockField) {
16          Collection<List<Capture>> capturesForAllBaseTypes = getCapturesForAllBaseTypes();
17  
18          for (List<Capture> fieldsWithCapture : capturesForAllBaseTypes) {
19              resetCaptureCount(mockField, fieldsWithCapture);
20          }
21      }
22  
23      private static void resetCaptureCount(@NonNull Field mockField, @NonNull List<Capture> fieldsWithCapture) {
24          for (Capture fieldWithCapture : fieldsWithCapture) {
25              if (fieldWithCapture.typeMetadata.field == mockField) {
26                  fieldWithCapture.reset();
27              }
28          }
29      }
30  }