Package: NamedTypeInfo

NamedTypeInfo

nameinstructionbranchcomplexitylinemethod
NamedTypeInfo(String, String, boolean, boolean, AbstractTypeInfo)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
consCheckExp(String, String, String, NameGen)
M: 0 C: 76
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 15
100%
M: 0 C: 1
100%
equals(Object)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getDefModule()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getDomainType()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getLeafTypesRecursively()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getTypeName()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hasInv()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 22 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
isSameTypeDef(NamedTypeInfo, String, String)
M: 4 C: 28
88%
M: 8 C: 8
50%
M: 6 C: 3
33%
M: 0 C: 7
100%
M: 0 C: 1
100%
toString()
M: 43 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.codegen.vdm2jml.predgen.info;
2:
3: import java.util.List;
4:
5: import org.overture.codegen.vdm2jml.JmlGenerator;
6: import org.overture.codegen.vdm2jml.util.NameGen;
7:
8: public class NamedTypeInfo extends AbstractTypeInfo
9: {
10:         private String typeName;
11:         private String defModule;
12:         private boolean hasInv;
13:         private AbstractTypeInfo domainType; // T = <domainType>
14:
15:         public NamedTypeInfo(String typeName, String defModule, boolean hasInv,
16:                         boolean optional, AbstractTypeInfo domainType)
17:         {
18:                 super(optional);
19:                 this.typeName = typeName;
20:                 this.defModule = defModule;
21:                 this.hasInv = hasInv;
22:                 this.domainType = domainType;
23:         }
24:
25:         public String getTypeName()
26:         {
27:                 return typeName;
28:         }
29:
30:         public String getDefModule()
31:         {
32:                 return defModule;
33:         }
34:
35:         public boolean hasInv()
36:         {
37:                 return hasInv;
38:         }
39:
40:         public AbstractTypeInfo getDomainType()
41:         {
42:                 return domainType;
43:         }
44:
45:         @Override
46:         public int hashCode()
47:         {
48:                 int hashCode = 0;
49:
50:•                if (defModule != null)
51:                 {
52:                         hashCode += defModule.hashCode();
53:                 }
54:
55:•                if (typeName != null)
56:                 {
57:                         hashCode += typeName.hashCode();
58:                 }
59:
60:                 return hashCode;
61:         }
62:
63:         @Override
64:         public boolean equals(Object obj)
65:         {
66:•                if (!(obj instanceof NamedTypeInfo))
67:                 {
68:                         return false;
69:                 }
70:
71:                 NamedTypeInfo other = (NamedTypeInfo) obj;
72:
73:                 return isSameTypeDef(this, other.defModule, other.typeName);
74:         }
75:
76:         public static boolean isSameTypeDef(NamedTypeInfo typeData,
77:                         String otherDefModule, String otherTypeName)
78:         {
79:•                if (typeData.defModule == null && otherDefModule != null
80:                                 || typeData.defModule != null
81:•                                                && !typeData.defModule.equals(otherDefModule))
82:                 {
83:                         return false;
84:                 }
85:
86:•                if (typeData.typeName == null && otherTypeName != null
87:                                 || typeData.typeName != null
88:•                                                && !typeData.typeName.equals(otherTypeName))
89:                 {
90:                         return false;
91:                 }
92:
93:                 // The defining module and the type name should form unique identification
94:
95:                 return true;
96:         }
97:
98:         @Override
99:         public String consCheckExp(String enclosingModule, String javaRootPackages,
100:                         String arg, NameGen nameGen)
101:         {
102:                 StringBuilder sb = new StringBuilder();
103:                 // // If the type is not defined in the enclosing class we use the absolute name
104:                 // // to refer to the invariant method
105:                 // if(!defModule.equals(enclosingModule))
106:                 // {
107:                 // sb.append(javaRootPackage);
108:                 // sb.append('.');
109:                 // sb.append(defModule);
110:                 // sb.append(".");
111:                 // }
112:
113:•                if (isOptional())
114:                 {
115:                         sb.append(consIsNullCheck(arg));
116:                         sb.append(JmlGenerator.JML_OR);
117:                 }
118:
119:•                if (domainType != null)
120:                 {
121:                         sb.append(domainType.consCheckExp(enclosingModule, javaRootPackages, arg, nameGen));
122:                         sb.append(JmlGenerator.JML_AND);
123:                 }
124:
125:                 sb.append(JmlGenerator.INV_PREFIX);
126:                 sb.append(defModule);
127:                 sb.append("_");
128:                 sb.append(typeName);
129:
130:                 sb.append('(');
131:                 sb.append(arg);
132:                 sb.append(')');
133:
134:                 return "(" + sb.toString() + ")";
135:         }
136:
137:         @Override
138:         public List<LeafTypeInfo> getLeafTypesRecursively()
139:         {
140:                 return domainType.getLeafTypesRecursively();
141:         }
142:
143:         @Override
144:         public String toString()
145:         {
146:                 StringBuilder sb = new StringBuilder();
147:
148:                 sb.append('(');
149:
150:•                if (isOptional())
151:                 {
152:                         sb.append("[");
153:                 }
154:
155:                 sb.append(this.typeName);
156:                 sb.append(" = ");
157:                 sb.append(domainType);
158:
159:•                if (isOptional())
160:                 {
161:                         sb.append("]");
162:                 }
163:
164:                 sb.append(')');
165:
166:                 return sb.toString();
167:         }
168: }