Package: UnionInfo

UnionInfo

nameinstructionbranchcomplexitylinemethod
UnionInfo(boolean, List)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
consCheckExp(String, String, String, NameGen)
M: 0 C: 55
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 13
100%
M: 0 C: 1
100%
getLeafTypesRecursively()
M: 0 C: 23
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
toString()
M: 54 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 14 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.codegen.vdm2jml.predgen.info;
2:
3: import java.util.LinkedList;
4: import java.util.List;
5:
6: import org.overture.codegen.vdm2jml.JmlGenerator;
7: import org.overture.codegen.vdm2jml.util.NameGen;
8:
9: public class UnionInfo extends AbstractTypeInfo
10: {
11:         private List<AbstractTypeInfo> types;
12:
13:         public UnionInfo(boolean optional, List<AbstractTypeInfo> types)
14:         {
15:                 super(optional);
16:                 this.types = types;
17:         }
18:
19:         @Override
20:         public List<LeafTypeInfo> getLeafTypesRecursively()
21:         {
22:                 List<LeafTypeInfo> leaves = new LinkedList<>();
23:
24:•                for (AbstractTypeInfo t : types)
25:                 {
26:                         leaves.addAll(t.getLeafTypesRecursively());
27:                 }
28:
29:                 return leaves;
30:         }
31:
32:         @Override
33:         public String consCheckExp(String enclosingModule, String javaRootPackage,
34:                         String arg, NameGen nameGen)
35:         {
36:                 StringBuilder sb = new StringBuilder();
37:
38:                 sb.append('(');
39:
40:                 String orSep = "";
41:•                if (isOptional())
42:                 {
43:                         sb.append(consIsNullCheck(arg));
44:                         orSep = JmlGenerator.JML_OR;
45:                 }
46:
47:•                for (AbstractTypeInfo currentType : types)
48:                 {
49:                         sb.append(orSep);
50:                         sb.append(currentType.consCheckExp(enclosingModule, javaRootPackage, arg, nameGen));
51:                         orSep = JmlGenerator.JML_OR;
52:                 }
53:
54:                 sb.append(')');
55:
56:                 return sb.toString();
57:         }
58:
59:         @Override
60:         public String toString()
61:         {
62:                 StringBuilder sb = new StringBuilder();
63:                 sb.append('(');
64:
65:•                if (isOptional())
66:                 {
67:                         sb.append("[");
68:                 }
69:
70:                 String sep = "";
71:•                for (AbstractTypeInfo t : types)
72:                 {
73:                         sb.append(sep);
74:                         sb.append(t.toString());
75:                         sep = "|";
76:                 }
77:
78:•                if (isOptional())
79:                 {
80:                         sb.append("]");
81:                 }
82:
83:                 sb.append(')');
84:
85:                 return sb.toString();
86:         }
87: }