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