Skip to content

Package: VIndexDomainModelReferenceImpl

VIndexDomainModelReferenceImpl

nameinstructionbranchcomplexitylinemethod
VIndexDomainModelReferenceImpl()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
basicSetPrefixDMR(VDomainModelReference, NotificationChain)
M: 18 C: 11
38%
M: 3 C: 1
25%
M: 2 C: 1
33%
M: 6 C: 4
40%
M: 0 C: 1
100%
basicSetTargetDMR(VDomainModelReference, NotificationChain)
M: 18 C: 11
38%
M: 3 C: 1
25%
M: 2 C: 1
33%
M: 6 C: 4
40%
M: 0 C: 1
100%
eGet(int, boolean, boolean)
M: 0 C: 18
100%
M: 0 C: 4
100%
M: 0 C: 4
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
eInverseRemove(InternalEObject, int, NotificationChain)
M: 18 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
eIsSet(int)
M: 0 C: 27
100%
M: 0 C: 10
100%
M: 0 C: 7
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
eSet(int, Object)
M: 5 C: 18
78%
M: 1 C: 3
75%
M: 1 C: 3
75%
M: 2 C: 7
78%
M: 0 C: 1
100%
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: 18 C: 0
0%
M: 4 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
getEStructuralFeatureIterator()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getIndex()
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%
getIterator()
M: 12 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getPrefixDMR()
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%
getTargetDMR()
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%
init(EObject)
M: 29 C: 73
72%
M: 9 C: 11
55%
M: 8 C: 3
27%
M: 5 C: 21
81%
M: 0 C: 1
100%
setIndex(int)
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%
setPrefixDMR(VDomainModelReference)
M: 25 C: 27
52%
M: 6 C: 4
40%
M: 5 C: 1
17%
M: 6 C: 9
60%
M: 0 C: 1
100%
setTargetDMR(VDomainModelReference)
M: 16 C: 36
69%
M: 4 C: 6
60%
M: 3 C: 3
50%
M: 4 C: 11
73%
M: 0 C: 1
100%
toString()
M: 3 C: 25
89%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 6
86%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2011-2014 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: * Eugen Neufeld - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.spi.indexdmr.model.impl;
15:
16: import java.util.Collections;
17: import java.util.Iterator;
18: import java.util.List;
19: import java.util.Set;
20:
21: import org.eclipse.emf.common.notify.Notification;
22: import org.eclipse.emf.common.notify.NotificationChain;
23: import org.eclipse.emf.ecore.EClass;
24: import org.eclipse.emf.ecore.EObject;
25: import org.eclipse.emf.ecore.EReference;
26: import org.eclipse.emf.ecore.EStructuralFeature;
27: import org.eclipse.emf.ecore.EStructuralFeature.Setting;
28: import org.eclipse.emf.ecore.InternalEObject;
29: import org.eclipse.emf.ecore.impl.ENotificationImpl;
30: import org.eclipse.emf.ecore.util.EcoreUtil;
31: import org.eclipse.emf.ecp.view.spi.indexdmr.model.VIndexDomainModelReference;
32: import org.eclipse.emf.ecp.view.spi.indexdmr.model.VIndexdmrPackage;
33: import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
34: import org.eclipse.emf.ecp.view.spi.model.impl.VFeaturePathDomainModelReferenceImpl;
35:
36: /**
37: * <!-- begin-user-doc -->
38: * An implementation of the model object '<em><b>Index Domain Model Reference</b></em>'.
39: * <!-- end-user-doc -->
40: * <p>
41: * The following features are implemented:
42: * <ul>
43: * <li>{@link org.eclipse.emf.ecp.view.spi.indexdmr.model.impl.VIndexDomainModelReferenceImpl#getPrefixDMR <em>Prefix
44: * DMR</em>}</li>
45: * <li>{@link org.eclipse.emf.ecp.view.spi.indexdmr.model.impl.VIndexDomainModelReferenceImpl#getIndex <em>Index</em>}
46: * </li>
47: * <li>{@link org.eclipse.emf.ecp.view.spi.indexdmr.model.impl.VIndexDomainModelReferenceImpl#getTargetDMR <em>Target
48: * DMR</em>}</li>
49: * </ul>
50: * </p>
51: *
52: * @generated
53: */
54: public class VIndexDomainModelReferenceImpl extends VFeaturePathDomainModelReferenceImpl implements
55:         VIndexDomainModelReference {
56:         /**
57:          * The cached value of the '{@link #getPrefixDMR() <em>Prefix DMR</em>}' containment reference.
58:          * <!-- begin-user-doc -->
59:          * <!-- end-user-doc -->
60:          *
61:          * @see #getPrefixDMR()
62:          * @generated
63:          * @ordered
64:          */
65:         protected VDomainModelReference prefixDMR;
66:
67:         /**
68:          * The default value of the '{@link #getIndex() <em>Index</em>}' attribute.
69:          * <!-- begin-user-doc -->
70:          * <!-- end-user-doc -->
71:          *
72:          * @see #getIndex()
73:          * @generated
74:          * @ordered
75:          */
76:         protected static final int INDEX_EDEFAULT = 0;
77:
78:         /**
79:          * The cached value of the '{@link #getIndex() <em>Index</em>}' attribute.
80:          * <!-- begin-user-doc -->
81:          * <!-- end-user-doc -->
82:          *
83:          * @see #getIndex()
84:          * @generated
85:          * @ordered
86:          */
87:         protected int index = INDEX_EDEFAULT;
88:
89:         /**
90:          * The cached value of the '{@link #getTargetDMR() <em>Target DMR</em>}' containment reference.
91:          * <!-- begin-user-doc -->
92:          * <!-- end-user-doc -->
93:          *
94:          * @see #getTargetDMR()
95:          * @generated
96:          * @ordered
97:          */
98:         protected VDomainModelReference targetDMR;
99:
100:         /**
101:          * <!-- begin-user-doc -->
102:          * <!-- end-user-doc -->
103:          *
104:          * @generated
105:          */
106:         protected VIndexDomainModelReferenceImpl() {
107:                 super();
108:         }
109:
110:         /**
111:          * <!-- begin-user-doc -->
112:          * <!-- end-user-doc -->
113:          *
114:          * @generated
115:          */
116:         @Override
117:         protected EClass eStaticClass() {
118:                 return VIndexdmrPackage.Literals.INDEX_DOMAIN_MODEL_REFERENCE;
119:         }
120:
121:         /**
122:          * <!-- begin-user-doc -->
123:          * <!-- end-user-doc -->
124:          *
125:          * @generated
126:          */
127:         @Override
128:         public VDomainModelReference getPrefixDMR() {
129:                 return prefixDMR;
130:         }
131:
132:         /**
133:          * <!-- begin-user-doc -->
134:          * <!-- end-user-doc -->
135:          *
136:          * @generated
137:          */
138:         public NotificationChain basicSetPrefixDMR(VDomainModelReference newPrefixDMR, NotificationChain msgs) {
139:                 final VDomainModelReference oldPrefixDMR = prefixDMR;
140:                 prefixDMR = newPrefixDMR;
141:•                if (eNotificationRequired()) {
142:                         final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
143:                                 VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR, oldPrefixDMR, newPrefixDMR);
144:•                        if (msgs == null) {
145:                                 msgs = notification;
146:                         } else {
147:                                 msgs.add(notification);
148:                         }
149:                 }
150:                 return msgs;
151:         }
152:
153:         /**
154:          * <!-- begin-user-doc -->
155:          * <!-- end-user-doc -->
156:          *
157:          * @generated
158:          */
159:         @Override
160:         public void setPrefixDMR(VDomainModelReference newPrefixDMR) {
161:•                if (newPrefixDMR != prefixDMR) {
162:                         NotificationChain msgs = null;
163:•                        if (prefixDMR != null) {
164:                                 msgs = ((InternalEObject) prefixDMR).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
165:                                         - VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR, null, msgs);
166:                         }
167:•                        if (newPrefixDMR != null) {
168:                                 msgs = ((InternalEObject) newPrefixDMR).eInverseAdd(this, EOPPOSITE_FEATURE_BASE
169:                                         - VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR, null, msgs);
170:                         }
171:                         msgs = basicSetPrefixDMR(newPrefixDMR, msgs);
172:•                        if (msgs != null) {
173:                                 msgs.dispatch();
174:                         }
175:•                } else if (eNotificationRequired()) {
176:                         eNotify(new ENotificationImpl(this, Notification.SET,
177:                                 VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR, newPrefixDMR, newPrefixDMR));
178:                 }
179:         }
180:
181:         /**
182:          * <!-- begin-user-doc -->
183:          * <!-- end-user-doc -->
184:          *
185:          * @generated
186:          */
187:         @Override
188:         public VDomainModelReference getTargetDMR() {
189:                 return targetDMR;
190:         }
191:
192:         /**
193:          * <!-- begin-user-doc -->
194:          * <!-- end-user-doc -->
195:          *
196:          * @generated
197:          */
198:         public NotificationChain basicSetTargetDMR(VDomainModelReference newTargetDMR, NotificationChain msgs) {
199:                 final VDomainModelReference oldTargetDMR = targetDMR;
200:                 targetDMR = newTargetDMR;
201:•                if (eNotificationRequired()) {
202:                         final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
203:                                 VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR, oldTargetDMR, newTargetDMR);
204:•                        if (msgs == null) {
205:                                 msgs = notification;
206:                         } else {
207:                                 msgs.add(notification);
208:                         }
209:                 }
210:                 return msgs;
211:         }
212:
213:         /**
214:          * <!-- begin-user-doc -->
215:          * <!-- end-user-doc -->
216:          *
217:          * @generated
218:          */
219:         @Override
220:         public void setTargetDMR(VDomainModelReference newTargetDMR) {
221:•                if (newTargetDMR != targetDMR) {
222:                         NotificationChain msgs = null;
223:•                        if (targetDMR != null) {
224:                                 msgs = ((InternalEObject) targetDMR).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
225:                                         - VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR, null, msgs);
226:                         }
227:•                        if (newTargetDMR != null) {
228:                                 msgs = ((InternalEObject) newTargetDMR).eInverseAdd(this, EOPPOSITE_FEATURE_BASE
229:                                         - VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR, null, msgs);
230:                         }
231:                         msgs = basicSetTargetDMR(newTargetDMR, msgs);
232:•                        if (msgs != null) {
233:                                 msgs.dispatch();
234:                         }
235:•                } else if (eNotificationRequired()) {
236:                         eNotify(new ENotificationImpl(this, Notification.SET,
237:                                 VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR, newTargetDMR, newTargetDMR));
238:                 }
239:         }
240:
241:         /**
242:          * <!-- begin-user-doc -->
243:          * <!-- end-user-doc -->
244:          *
245:          * @generated
246:          */
247:         @Override
248:         public int getIndex() {
249:                 return index;
250:         }
251:
252:         /**
253:          * <!-- begin-user-doc -->
254:          * <!-- end-user-doc -->
255:          *
256:          * @generated
257:          */
258:         @Override
259:         public void setIndex(int newIndex) {
260:                 final int oldIndex = index;
261:                 index = newIndex;
262:•                if (eNotificationRequired()) {
263:                         eNotify(new ENotificationImpl(this, Notification.SET, VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__INDEX,
264:                                 oldIndex, index));
265:                 }
266:         }
267:
268:         /**
269:          * <!-- begin-user-doc -->
270:          * <!-- end-user-doc -->
271:          *
272:          * @generated
273:          */
274:         @Override
275:         public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
276:•                switch (featureID) {
277:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR:
278:                         return basicSetPrefixDMR(null, msgs);
279:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR:
280:                         return basicSetTargetDMR(null, msgs);
281:                 }
282:                 return super.eInverseRemove(otherEnd, featureID, msgs);
283:         }
284:
285:         /**
286:          * <!-- begin-user-doc -->
287:          * <!-- end-user-doc -->
288:          *
289:          * @generated
290:          */
291:         @Override
292:         public Object eGet(int featureID, boolean resolve, boolean coreType) {
293:•                switch (featureID) {
294:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR:
295:                         return getPrefixDMR();
296:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__INDEX:
297:                         return getIndex();
298:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR:
299:                         return getTargetDMR();
300:                 }
301:                 return super.eGet(featureID, resolve, coreType);
302:         }
303:
304:         /**
305:          * <!-- begin-user-doc -->
306:          * <!-- end-user-doc -->
307:          *
308:          * @generated
309:          */
310:         @Override
311:         public void eSet(int featureID, Object newValue) {
312:•                switch (featureID) {
313:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR:
314:                         setPrefixDMR((VDomainModelReference) newValue);
315:                         return;
316:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__INDEX:
317:                         setIndex((Integer) newValue);
318:                         return;
319:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR:
320:                         setTargetDMR((VDomainModelReference) newValue);
321:                         return;
322:                 }
323:                 super.eSet(featureID, newValue);
324:         }
325:
326:         /**
327:          * <!-- begin-user-doc -->
328:          * <!-- end-user-doc -->
329:          *
330:          * @generated
331:          */
332:         @Override
333:         public void eUnset(int featureID) {
334:•                switch (featureID) {
335:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR:
336:                         setPrefixDMR((VDomainModelReference) null);
337:                         return;
338:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__INDEX:
339:                         setIndex(INDEX_EDEFAULT);
340:                         return;
341:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR:
342:                         setTargetDMR((VDomainModelReference) null);
343:                         return;
344:                 }
345:                 super.eUnset(featureID);
346:         }
347:
348:         /**
349:          * <!-- begin-user-doc -->
350:          * <!-- end-user-doc -->
351:          *
352:          * @generated
353:          */
354:         @Override
355:         public boolean eIsSet(int featureID) {
356:•                switch (featureID) {
357:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__PREFIX_DMR:
358:•                        return prefixDMR != null;
359:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__INDEX:
360:•                        return index != INDEX_EDEFAULT;
361:                 case VIndexdmrPackage.INDEX_DOMAIN_MODEL_REFERENCE__TARGET_DMR:
362:•                        return targetDMR != null;
363:                 }
364:                 return super.eIsSet(featureID);
365:         }
366:
367:         /**
368:          * <!-- begin-user-doc -->
369:          * <!-- end-user-doc -->
370:          *
371:          * @generated
372:          */
373:         @Override
374:         public String toString() {
375:•                if (eIsProxy()) {
376:                         return super.toString();
377:                 }
378:
379:                 final StringBuffer result = new StringBuffer(super.toString());
380:                 result.append(" (index: "); //$NON-NLS-1$
381:                 result.append(index);
382:                 result.append(')');
383:                 return result.toString();
384:         }
385:
386:         /**
387:          * {@inheritDoc}
388:          *
389:          * @see org.eclipse.emf.ecp.view.spi.model.impl.VFeaturePathDomainModelReferenceImpl#init(org.eclipse.emf.ecore.EObject)
390:          */
391:         @SuppressWarnings("unchecked")
392:         @Deprecated
393:         @Override
394:         public boolean init(EObject eObject) {
395:•                if (getTargetDMR() == null) {
396:                         return false;
397:                 }
398:•                if (getIndex() < 0) {
399:                         return false;
400:                 }
401:                 boolean init;
402:•                if (getPrefixDMR() == null) {
403:                         init = super.init(eObject);
404:                 } else {
405:                         init = getPrefixDMR().init(eObject);
406:                 }
407:
408:                 List<EObject> list;
409:•                if (getPrefixDMR() == null) {
410:                         list = (List<EObject>) lastResolvedEObject.eGet(getDomainModelEFeature());
411:                 } else {
412:                         list = (List<EObject>) getPrefixDMR().getIterator().next().get(true);
413:                 }
414:
415:•                if (list.size() < getIndex() && getIndex() != 0) {
416:                         return false;
417:                 }
418:                 EObject foundChild = null;
419:•                if (list.size() == getIndex()) {
420:                         EReference eReference;
421:•                        if (getPrefixDMR() == null) {
422:                                 eReference = (EReference) getDomainModelEFeature();
423:                         } else {
424:                                 eReference = (EReference) getPrefixDMR().getEStructuralFeatureIterator().next();
425:                         }
426:                         foundChild = EcoreUtil.create(eReference.getEReferenceType());
427:                         list.add(foundChild);
428:                 } else {
429:                         foundChild = list.get(getIndex());
430:                 }
431:
432:                 final boolean valueDMR = getTargetDMR().init(foundChild);
433:•                return init && valueDMR;
434:         }
435:
436:         @Deprecated
437:         @Override
438:         public Iterator<Setting> getIterator() {
439:•                if (getTargetDMR() == null) {
440:                         final Set<Setting> settings = Collections.emptySet();
441:                         return settings.iterator();
442:                 }
443:                 return getTargetDMR().getIterator();
444:         }
445:
446:         @Deprecated
447:         @Override
448:         public Iterator<EStructuralFeature> getEStructuralFeatureIterator() {
449:•                if (getTargetDMR() == null) {
450:                         final Set<EStructuralFeature> features = Collections.emptySet();
451:                         return features.iterator();
452:                 }
453:                 return getTargetDMR().getEStructuralFeatureIterator();
454:         }
455:
456: } // VIndexDomainModelReferenceImpl