Skip to content

Package: NamedVariableType

NamedVariableType

nameinstructionbranchcomplexitylinemethod
NamedVariableType(String, RegEx, String, Position)
M: 0 C: 23
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
accept(AbstractVariableTypeVisitor)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addInCondition(TypeExtensionWithCondition)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addTypeExtension(TypeExtension)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
checkTypeExtensionConditions()
M: 7 C: 8
53%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 2
50%
M: 0 C: 1
100%
deleteInCondition(TypeExtensionWithCondition)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
equals(Object)
M: 0 C: 35
100%
M: 2 C: 8
80%
M: 2 C: 4
67%
M: 0 C: 5
100%
M: 0 C: 1
100%
getErrorMessage()
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%
getInConditions()
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%
getName()
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%
getPosition()
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%
getRepString()
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%
getTypeExtensions()
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: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
print()
M: 0 C: 35
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
toStringResolved()
M: 21 C: 13
38%
M: 3 C: 1
25%
M: 2 C: 1
33%
M: 3 C: 3
50%
M: 0 C: 1
100%

Coverage

1: package model.type;
2:
3: import java.util.ArrayList;
4: import java.util.List;
5:
6: import model.Position;
7:
8: /**
9: * Represents a type of an definition. An entry from the TypeFile.
10: *
11: * @author HFW410RA - Philipp Rammos
12: *
13: */
14: public class NamedVariableType extends AbstractVariableType {
15:         /**
16:          * Represents the name of the type.
17:          */
18:         private final String name;
19:         /**
20:          * Represents the error message of the type.
21:          */
22:         private final String errorMessage;
23:
24:         /**
25:          * row where the entry is written.
26:          */
27:         private final Position position;
28:
29:         /**
30:          * My type extension which extend my regular expression.
31:          */
32:         private final List<TypeExtension> typeExtensions = new ArrayList<>();
33:
34:         /**
35:          * List of TypeExtensionVariable in which condition this is referenced.
36:          */
37:         private final List<TypeExtensionWithCondition> inConditions = new ArrayList<>();
38:
39:         /**
40:          * Constructor, just sets the fields. No side effects.
41:          *
42:          * @param name
43:          * The name to set.
44:          * @param expression
45:          * the expression to set.
46:          * @param errorMessage
47:          * the error message to set
48:          * @param position
49:          * The psition to set.
50:          */
51:         public NamedVariableType(final String name, final RegEx expression, final String errorMessage,
52:                         final Position position) {
53:                 super(expression);
54:                 this.name = name;
55:                 this.errorMessage = errorMessage;
56:                 this.position = position;
57:         }
58:
59:         @Override
60:         public boolean equals(final Object obj) {
61:•                return obj instanceof NamedVariableType
62:•                                && ((NamedVariableType) obj).getName().equals(this.getName())
63:•                                && ((NamedVariableType) obj).getExpression().equals(this.getExpression())
64:•                                && ((NamedVariableType) obj).getErrorMessage().equals(this.getErrorMessage())
65:•                                && ((NamedVariableType) obj).getPosition().equals(this.getPosition());
66:         }
67:
68:         @Override
69:         public int hashCode() {
70:                 return this.getName().hashCode() + this.getExpression().hashCode()
71:                                 + this.getErrorMessage().hashCode() + this.getPosition().hashCode();
72:         }
73:
74:         /**
75:          * Returns the field row. No side effects.
76:          *
77:          * @return this.row
78:          */
79:         public Position getPosition() {
80:                 return this.position;
81:         }
82:
83:         /**
84:          * Return the field name. No side effects.
85:          *
86:          * @return this.name
87:          */
88:         public String getName() {
89:                 return this.name;
90:         }
91:
92:         /**
93:          * Return the field errorMessage. No side effects.
94:          *
95:          * @return this.errorMessage
96:          */
97:         @Override
98:         public String getErrorMessage() {
99:                 return this.errorMessage;
100:         }
101:
102:         /**
103:          * Returns the line to print.
104:          *
105:          * @return Returns a string value, representing a line to print.
106:          */
107:         @Override
108:         public String print() {
109:                 return this.getName() + basic.PrinterConstants.SPACE + scanner.ScannerConstants.EQUALSIGN
110:                                 + basic.PrinterConstants.SPACE + basic.PrinterConstants.SINGLEQUOT
111:                                 + this.getExpression().toStringUnresolved() + basic.PrinterConstants.SINGLEQUOT
112:                                 + basic.PrinterConstants.SPACE + scanner.ScannerConstants.COLONSIGN
113:                                 + basic.PrinterConstants.SPACE + basic.PrinterConstants.SINGLEQUOT
114:                                 + this.getErrorMessage() + basic.PrinterConstants.SINGLEQUOT;
115:         }
116:
117:         @Override
118:         public String getRepString() {
119:                 return this.name;
120:         }
121:
122:         /**
123:          * Adds a extension to the extension list.
124:          *
125:          * @param typExtension
126:          * The extension to add.
127:          */
128:         public void addTypeExtension(final TypeExtension typExtension) {
129:                 this.typeExtensions.add(typExtension);
130:
131:         }
132:
133:         /**
134:          * Returns the type extensions.
135:          *
136:          * @return Returns type extensions.
137:          */
138:         public List<TypeExtension> getTypeExtensions() {
139:                 return typeExtensions;
140:         }
141:
142:         /**
143:          * Returns the resolved string of the regexpart, with extensions and withOUT references like
144:          * (RE:LABEL).
145:          *
146:          * @return string
147:          * @throws ReferenceIsUnresolvedException
148:          * If a part is unresolved.
149:          */
150:         @Override
151:         public String toStringResolved() throws ReferenceIsUnresolvedException {
152:                 String result = this.getExpression().toStringResolved();
153:
154:•                for (TypeExtension typeExtension : getTypeExtensions()) {
155:•                        if (typeExtension.isVariableConditionFlag()) {
156:                                 result = result + "|" + typeExtension.getExpression().toStringResolved();
157:                         }
158:                 }
159:                 return result;
160:         }
161:
162:         /**
163:          * Get getInConditions.
164:          *
165:          * @return get inConditions.
166:          */
167:         public List<TypeExtensionWithCondition> getInConditions() {
168:                 return inConditions;
169:         }
170:
171:         /**
172:          * Add a typeExtensionVariable to the list of TypeExtensionVariable.
173:          *
174:          * @param typeExtensionVariable
175:          * The typeExtensionVariable to add.
176:          */
177:         public void addInCondition(final TypeExtensionWithCondition typeExtensionVariable) {
178:                 this.getInConditions().add(typeExtensionVariable);
179:         }
180:
181:         /**
182:          * Delete a typeExtensionVariable to the list of TypeExtensionVariable.
183:          *
184:          * @param typeExtensionVariable
185:          * The typeExtensionVariable to delete.
186:          */
187:         public void deleteInCondition(final TypeExtensionWithCondition typeExtensionVariable) {
188:                 this.getInConditions().remove(typeExtensionVariable);
189:         }
190:
191:         /**
192:          * Is executed if the varaibleassignment for this NamedVaraibleType has changed or during the
193:          * initialization in the CheckingConditionPhase.
194:          *
195:          * @throws ReferenceIsUnresolvedException
196:          * The ReferenceIsUnresolvedException.
197:          * @throws IllegalArgumentException
198:          * The IllegalArgumentException.
199:          *
200:          */
201:         public void checkTypeExtensionConditions()
202:                         throws IllegalArgumentException, ReferenceIsUnresolvedException {
203:•                for (TypeExtensionWithCondition typeExtensionVariable : inConditions) {
204:                         typeExtensionVariable.checkValidation();
205:                 }
206:         }
207:
208:         @Override
209:         public void accept(final AbstractVariableTypeVisitor vis)
210:                         throws TypeDoesNotExistException, TypeExceptions {
211:                 vis.visit(this);
212:         }
213:
214: }