Skip to content

Package: TestElementImpl

TestElementImpl

nameinstructionbranchcomplexitylinemethod
TestElementImpl()
M: 0 C: 12
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
eGet(int, boolean, boolean)
M: 9 C: 11
55%
M: 2 C: 3
60%
M: 2 C: 3
60%
M: 2 C: 4
67%
M: 0 C: 1
100%
eInverseRemove(InternalEObject, int, NotificationChain)
M: 15 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
eIsSet(int)
M: 38 C: 33
46%
M: 15 C: 12
44%
M: 11 C: 5
31%
M: 1 C: 5
83%
M: 0 C: 1
100%
eSet(int, Object)
M: 32 C: 0
0%
M: 5 C: 0
0%
M: 5 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
eStaticClass()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
eUnset(int)
M: 22 C: 0
0%
M: 5 C: 0
0%
M: 5 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
getElements()
M: 14 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getId()
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%
getParentId()
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%
setId(String)
M: 11 C: 10
48%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 4
80%
M: 0 C: 1
100%
setName(String)
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
setParentId(String)
M: 11 C: 10
48%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 4
67%
M: 0 C: 1
100%
static {...}
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%
toString()
M: 3 C: 43
93%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 10
91%
M: 0 C: 1
100%
validate(DiagnosticChain, Map)
M: 0 C: 33
100%
M: 2 C: 4
67%
M: 2 C: 2
50%
M: 0 C: 9
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Edgar Mueller - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.dynamictree.model.impl;
15:
16: import java.util.Collection;
17: import java.util.Map;
18:
19: import org.eclipse.emf.common.notify.Notification;
20: import org.eclipse.emf.common.notify.NotificationChain;
21: import org.eclipse.emf.common.util.BasicDiagnostic;
22: import org.eclipse.emf.common.util.Diagnostic;
23: import org.eclipse.emf.common.util.DiagnosticChain;
24: import org.eclipse.emf.common.util.EList;
25: import org.eclipse.emf.ecore.EClass;
26: import org.eclipse.emf.ecore.InternalEObject;
27: import org.eclipse.emf.ecore.impl.ENotificationImpl;
28: import org.eclipse.emf.ecore.impl.EObjectImpl;
29: import org.eclipse.emf.ecore.util.EObjectContainmentEList;
30: import org.eclipse.emf.ecore.util.InternalEList;
31: import org.eclipse.emf.ecp.view.dynamictree.model.ModelPackage;
32: import org.eclipse.emf.ecp.view.dynamictree.model.TestElement;
33: import org.eclipse.emf.ecp.view.dynamictree.model.util.ModelValidator;
34:
35: /**
36: * <!-- begin-user-doc -->
37: * An implementation of the model object '<em><b>Test Element</b></em>'.
38: * <!-- end-user-doc -->
39: * <p>
40: * The following features are implemented:
41: * <ul>
42: * <li>{@link org.eclipse.emf.ecp.view.dynamictree.model.impl.TestElementImpl#getId <em>Id</em>}</li>
43: * <li>{@link org.eclipse.emf.ecp.view.dynamictree.model.impl.TestElementImpl#getElements <em>Elements</em>}</li>
44: * <li>{@link org.eclipse.emf.ecp.view.dynamictree.model.impl.TestElementImpl#getParentId <em>Parent Id</em>}</li>
45: * <li>{@link org.eclipse.emf.ecp.view.dynamictree.model.impl.TestElementImpl#getName <em>Name</em>}</li>
46: * </ul>
47: * </p>
48: *
49: * @generated
50: */
51: public class TestElementImpl extends EObjectImpl implements TestElement {
52:         /**
53:          * The default value of the '{@link #getId() <em>Id</em>}' attribute.
54:          * <!-- begin-user-doc -->
55:          * <!-- end-user-doc -->
56:          *
57:          * @see #getId()
58:          * @generated
59:          * @ordered
60:          */
61:         protected static final String ID_EDEFAULT = null;
62:
63:         /**
64:          * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
65:          * <!-- begin-user-doc -->
66:          * <!-- end-user-doc -->
67:          *
68:          * @see #getId()
69:          * @generated
70:          * @ordered
71:          */
72:         protected String id = ID_EDEFAULT;
73:
74:         /**
75:          * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list.
76:          * <!-- begin-user-doc -->
77:          * <!-- end-user-doc -->
78:          *
79:          * @see #getElements()
80:          * @generated
81:          * @ordered
82:          */
83:         protected EList<TestElement> elements;
84:
85:         /**
86:          * The default value of the '{@link #getParentId() <em>Parent Id</em>}' attribute.
87:          * <!-- begin-user-doc -->
88:          * <!-- end-user-doc -->
89:          *
90:          * @see #getParentId()
91:          * @generated
92:          * @ordered
93:          */
94:         protected static final String PARENT_ID_EDEFAULT = null;
95:
96:         /**
97:          * The cached value of the '{@link #getParentId() <em>Parent Id</em>}' attribute.
98:          * <!-- begin-user-doc -->
99:          * <!-- end-user-doc -->
100:          *
101:          * @see #getParentId()
102:          * @generated
103:          * @ordered
104:          */
105:         protected String parentId = PARENT_ID_EDEFAULT;
106:
107:         /**
108:          * The default value of the '{@link #getName() <em>Name</em>}' attribute.
109:          * <!-- begin-user-doc -->
110:          * <!-- end-user-doc -->
111:          *
112:          * @see #getName()
113:          * @generated
114:          * @ordered
115:          */
116:         protected static final String NAME_EDEFAULT = null;
117:
118:         /**
119:          * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
120:          * <!-- begin-user-doc -->
121:          * <!-- end-user-doc -->
122:          *
123:          * @see #getName()
124:          * @generated
125:          * @ordered
126:          */
127:         protected String name = NAME_EDEFAULT;
128:
129:         /**
130:          * <!-- begin-user-doc -->
131:          * <!-- end-user-doc -->
132:          *
133:          * @generated
134:          */
135:         protected TestElementImpl() {
136:                 super();
137:         }
138:
139:         /**
140:          * <!-- begin-user-doc -->
141:          * <!-- end-user-doc -->
142:          *
143:          * @generated
144:          */
145:         @Override
146:         protected EClass eStaticClass() {
147:                 return ModelPackage.Literals.TEST_ELEMENT;
148:         }
149:
150:         /**
151:          * <!-- begin-user-doc -->
152:          * <!-- end-user-doc -->
153:          *
154:          * @generated
155:          */
156:         @Override
157:         public String getId() {
158:                 return id;
159:         }
160:
161:         /**
162:          * <!-- begin-user-doc -->
163:          * <!-- end-user-doc -->
164:          *
165:          * @generated
166:          */
167:         @Override
168:         public void setId(String newId) {
169:                 final String oldId = id;
170:                 id = newId;
171:•                if (eNotificationRequired()) {
172:                         eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.TEST_ELEMENT__ID, oldId, id));
173:                 }
174:         }
175:
176:         /**
177:          * <!-- begin-user-doc -->
178:          * <!-- end-user-doc -->
179:          *
180:          * @generated
181:          */
182:         @Override
183:         public EList<TestElement> getElements() {
184:•                if (elements == null) {
185:                         elements = new EObjectContainmentEList<TestElement>(TestElement.class, this,
186:                                 ModelPackage.TEST_ELEMENT__ELEMENTS);
187:                 }
188:                 return elements;
189:         }
190:
191:         /**
192:          * <!-- begin-user-doc -->
193:          * <!-- end-user-doc -->
194:          *
195:          * @generated
196:          */
197:         @Override
198:         public String getParentId() {
199:                 return parentId;
200:         }
201:
202:         /**
203:          * <!-- begin-user-doc -->
204:          * <!-- end-user-doc -->
205:          *
206:          * @generated
207:          */
208:         @Override
209:         public void setParentId(String newParentId) {
210:                 final String oldParentId = parentId;
211:                 parentId = newParentId;
212:•                if (eNotificationRequired()) {
213:                         eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.TEST_ELEMENT__PARENT_ID, oldParentId,
214:                                 parentId));
215:                 }
216:         }
217:
218:         /**
219:          * <!-- begin-user-doc -->
220:          * <!-- end-user-doc -->
221:          *
222:          * @generated
223:          */
224:         @Override
225:         public String getName() {
226:                 return name;
227:         }
228:
229:         /**
230:          * <!-- begin-user-doc -->
231:          * <!-- end-user-doc -->
232:          *
233:          * @generated
234:          */
235:         @Override
236:         public void setName(String newName) {
237:                 final String oldName = name;
238:                 name = newName;
239:•                if (eNotificationRequired()) {
240:                         eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.TEST_ELEMENT__NAME, oldName, name));
241:                 }
242:         }
243:
244:         /**
245:          * <!-- begin-user-doc -->
246:          *
247:          * Validates this test element.
248:          *
249:          * @param diagnostic
250:          * the diagnostic chain
251:          * @param context
252:          * the context
253:          *
254:          * @return {@code true} if this element is valid, {@code false} otherwise
255:          *
256:          * <!-- end-user-doc -->
257:          *
258:          * @generated NOT
259:          */
260:         @Override
261:         public boolean validate(DiagnosticChain diagnostic, Map<?, ?> context) {
262:•                if (getName() == null || getName().length() == 0) {
263:•                        if (diagnostic != null) {
264:                                 diagnostic.add(new BasicDiagnostic(Diagnostic.ERROR,
265:                                         ModelValidator.DIAGNOSTIC_SOURCE,
266:                                         ModelValidator.TEST_ELEMENT__VALIDATE,
267:                                         "Invalid name (custom validation rule).",
268:                                         new Object[] { this, ModelPackage.eINSTANCE.getTestElement_Name()
269:                                         }));
270:                         }
271:                         return false;
272:                 }
273:                 return true;
274:         }
275:
276:         /**
277:          * <!-- begin-user-doc -->
278:          * .
279:          * <!-- end-user-doc -->
280:          *
281:          * @generated
282:          */
283:         @Override
284:         public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
285:•                switch (featureID) {
286:                 case ModelPackage.TEST_ELEMENT__ELEMENTS:
287:                         return ((InternalEList<?>) getElements()).basicRemove(otherEnd, msgs);
288:                 }
289:                 return super.eInverseRemove(otherEnd, featureID, msgs);
290:         }
291:
292:         /**
293:          * <!-- begin-user-doc -->
294:          * <!-- end-user-doc -->
295:          *
296:          * @generated
297:          */
298:         @Override
299:         public Object eGet(int featureID, boolean resolve, boolean coreType) {
300:•                switch (featureID) {
301:                 case ModelPackage.TEST_ELEMENT__ID:
302:                         return getId();
303:                 case ModelPackage.TEST_ELEMENT__ELEMENTS:
304:                         return getElements();
305:                 case ModelPackage.TEST_ELEMENT__PARENT_ID:
306:                         return getParentId();
307:                 case ModelPackage.TEST_ELEMENT__NAME:
308:                         return getName();
309:                 }
310:                 return super.eGet(featureID, resolve, coreType);
311:         }
312:
313:         /**
314:          * <!-- begin-user-doc -->
315:          * <!-- end-user-doc -->
316:          *
317:          * @generated
318:          */
319:         @SuppressWarnings("unchecked")
320:         @Override
321:         public void eSet(int featureID, Object newValue) {
322:•                switch (featureID) {
323:                 case ModelPackage.TEST_ELEMENT__ID:
324:                         setId((String) newValue);
325:                         return;
326:                 case ModelPackage.TEST_ELEMENT__ELEMENTS:
327:                         getElements().clear();
328:                         getElements().addAll((Collection<? extends TestElement>) newValue);
329:                         return;
330:                 case ModelPackage.TEST_ELEMENT__PARENT_ID:
331:                         setParentId((String) newValue);
332:                         return;
333:                 case ModelPackage.TEST_ELEMENT__NAME:
334:                         setName((String) newValue);
335:                         return;
336:                 }
337:                 super.eSet(featureID, newValue);
338:         }
339:
340:         /**
341:          * <!-- begin-user-doc -->
342:          * <!-- end-user-doc -->
343:          *
344:          * @generated
345:          */
346:         @Override
347:         public void eUnset(int featureID) {
348:•                switch (featureID) {
349:                 case ModelPackage.TEST_ELEMENT__ID:
350:                         setId(ID_EDEFAULT);
351:                         return;
352:                 case ModelPackage.TEST_ELEMENT__ELEMENTS:
353:                         getElements().clear();
354:                         return;
355:                 case ModelPackage.TEST_ELEMENT__PARENT_ID:
356:                         setParentId(PARENT_ID_EDEFAULT);
357:                         return;
358:                 case ModelPackage.TEST_ELEMENT__NAME:
359:                         setName(NAME_EDEFAULT);
360:                         return;
361:                 }
362:                 super.eUnset(featureID);
363:         }
364:
365:         /**
366:          * <!-- begin-user-doc -->
367:          * <!-- end-user-doc -->
368:          *
369:          * @generated
370:          */
371:         @Override
372:         public boolean eIsSet(int featureID) {
373:•                switch (featureID) {
374:                 case ModelPackage.TEST_ELEMENT__ID:
375:•                        return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
376:                 case ModelPackage.TEST_ELEMENT__ELEMENTS:
377:•                        return elements != null && !elements.isEmpty();
378:                 case ModelPackage.TEST_ELEMENT__PARENT_ID:
379:•                        return PARENT_ID_EDEFAULT == null ? parentId != null : !PARENT_ID_EDEFAULT.equals(parentId);
380:                 case ModelPackage.TEST_ELEMENT__NAME:
381:•                        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
382:                 }
383:                 return super.eIsSet(featureID);
384:         }
385:
386:         /**
387:          * <!-- begin-user-doc -->
388:          * <!-- end-user-doc -->
389:          *
390:          * @generated
391:          */
392:         @Override
393:         public String toString() {
394:•                if (eIsProxy()) {
395:                         return super.toString();
396:                 }
397:
398:                 final StringBuffer result = new StringBuffer(super.toString());
399:                 result.append(" (id: ");
400:                 result.append(id);
401:                 result.append(", parentId: ");
402:                 result.append(parentId);
403:                 result.append(", name: ");
404:                 result.append(name);
405:                 result.append(')');
406:                 return result.toString();
407:         }
408:
409: } // TestElementImpl