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