1
2
3
4
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 }