1
2
3
4
5
6 package mockit.coverage.lines;
7
8 import edu.umd.cs.findbugs.annotations.NonNull;
9
10 import java.io.IOException;
11 import java.io.ObjectInputStream;
12 import java.io.ObjectOutputStream;
13
14 import mockit.asm.controlFlow.Label;
15
16 import org.checkerframework.checker.index.qual.NonNegative;
17
18
19
20
21 public final class BranchCoverageData extends LineSegmentData {
22 private static final long serialVersionUID = 1003335601845442606L;
23 static final BranchCoverageData INVALID = new BranchCoverageData(new Label());
24
25 @NonNull
26 private transient Label label;
27
28 BranchCoverageData(@NonNull Label label) {
29 this.label = label;
30 }
31
32 @Override
33 public boolean isEmpty() {
34 return empty || label.line == 0 && label.jumpTargetLine == 0;
35 }
36
37 @NonNegative
38 int getLine() {
39 return label.jumpTargetLine == 0 ? label.line : label.jumpTargetLine;
40 }
41
42 private void readObject(@NonNull ObjectInputStream in) throws IOException, ClassNotFoundException {
43 label = new Label();
44 label.line = in.readInt();
45 in.defaultReadObject();
46 }
47
48 private void writeObject(@NonNull ObjectOutputStream out) throws IOException {
49 int line = getLine();
50 out.writeInt(line);
51 out.defaultWriteObject();
52 }
53 }