Skip to content

Package: VTViewModelElementSelectorImpl

VTViewModelElementSelectorImpl

nameinstructionbranchcomplexitylinemethod
VTViewModelElementSelectorImpl()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
basicGetAttribute()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
basicGetClassType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
eGet(int, boolean, boolean)
M: 12 C: 19
61%
M: 3 C: 6
67%
M: 3 C: 4
57%
M: 3 C: 7
70%
M: 0 C: 1
100%
eIsSet(int)
M: 16 C: 25
61%
M: 6 C: 9
60%
M: 5 C: 5
50%
M: 3 C: 5
63%
M: 0 C: 1
100%
eSet(int, Object)
M: 20 C: 7
26%
M: 4 C: 1
20%
M: 4 C: 1
20%
M: 8 C: 3
27%
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: 22 C: 0
0%
M: 5 C: 0
0%
M: 5 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
getAttribute()
M: 32 C: 6
16%
M: 7 C: 1
13%
M: 4 C: 1
20%
M: 6 C: 2
25%
M: 0 C: 1
100%
getAttributeValue()
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%
getClassType()
M: 11 C: 27
71%
M: 2 C: 6
75%
M: 2 C: 3
60%
M: 2 C: 6
75%
M: 0 C: 1
100%
isApplicable(VElement, ViewModelContext)
M: 3 C: 52
95%
M: 1 C: 15
94%
M: 1 C: 8
89%
M: 1 C: 13
93%
M: 0 C: 1
100%
isSelectSubclasses()
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%
setAttribute(EAttribute)
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%
setAttributeValue(Object)
M: 11 C: 10
48%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 3 C: 4
57%
M: 0 C: 1
100%
setClassType(EClass)
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%
setSelectSubclasses(boolean)
M: 11 C: 10
48%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 3 C: 4
57%
M: 0 C: 1
100%
static {...}
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%
toString()
M: 37 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%

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: * EclipseSource Munich - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.impl;
15:
16: import org.eclipse.emf.common.notify.Notification;
17: import org.eclipse.emf.ecore.EAttribute;
18: import org.eclipse.emf.ecore.EClass;
19: import org.eclipse.emf.ecore.InternalEObject;
20: import org.eclipse.emf.ecore.impl.ENotificationImpl;
21: import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
22: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
23: import org.eclipse.emf.ecp.view.spi.model.VElement;
24: import org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.VTViewModelElementPackage;
25: import org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.VTViewModelElementSelector;
26:
27: /**
28: * <!-- begin-user-doc -->
29: * An implementation of the model object '<em><b>Selector</b></em>'.
30: * <!-- end-user-doc -->
31: * <p>
32: * The following features are implemented:
33: * <ul>
34: * <li>
35: * {@link org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.impl.VTViewModelElementSelectorImpl#isSelectSubclasses
36: * <em>Select Subclasses</em>}</li>
37: * <li>
38: * {@link org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.impl.VTViewModelElementSelectorImpl#getClassType
39: * <em>Class Type</em>}</li>
40: * <li>
41: * {@link org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.impl.VTViewModelElementSelectorImpl#getAttribute
42: * <em>Attribute</em>}</li>
43: * <li>
44: * {@link org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.impl.VTViewModelElementSelectorImpl#getAttributeValue
45: * <em>Attribute Value</em>}</li>
46: * </ul>
47: * </p>
48: *
49: * @generated
50: */
51: public class VTViewModelElementSelectorImpl extends MinimalEObjectImpl.Container implements VTViewModelElementSelector {
52:         /**
53:          * The default value of the '{@link #isSelectSubclasses() <em>Select Subclasses</em>}' attribute.
54:          * <!-- begin-user-doc -->
55:          * <!-- end-user-doc -->
56:          *
57:          * @see #isSelectSubclasses()
58:          * @generated
59:          * @ordered
60:          */
61:         protected static final boolean SELECT_SUBCLASSES_EDEFAULT = false;
62:
63:         /**
64:          * The cached value of the '{@link #isSelectSubclasses() <em>Select Subclasses</em>}' attribute.
65:          * <!-- begin-user-doc -->
66:          * <!-- end-user-doc -->
67:          *
68:          * @see #isSelectSubclasses()
69:          * @generated
70:          * @ordered
71:          */
72:         protected boolean selectSubclasses = SELECT_SUBCLASSES_EDEFAULT;
73:
74:         /**
75:          * The cached value of the '{@link #getClassType() <em>Class Type</em>}' reference.
76:          * <!-- begin-user-doc -->
77:          * <!-- end-user-doc -->
78:          *
79:          * @see #getClassType()
80:          * @generated
81:          * @ordered
82:          */
83:         protected EClass classType;
84:
85:         /**
86:          * The cached value of the '{@link #getAttribute() <em>Attribute</em>}' reference.
87:          * <!-- begin-user-doc -->
88:          * <!-- end-user-doc -->
89:          *
90:          * @see #getAttribute()
91:          * @generated
92:          * @ordered
93:          */
94:         protected EAttribute attribute;
95:
96:         /**
97:          * The default value of the '{@link #getAttributeValue() <em>Attribute Value</em>}' attribute.
98:          * <!-- begin-user-doc -->
99:          * <!-- end-user-doc -->
100:          *
101:          * @see #getAttributeValue()
102:          * @generated
103:          * @ordered
104:          */
105:         protected static final Object ATTRIBUTE_VALUE_EDEFAULT = null;
106:
107:         /**
108:          * The cached value of the '{@link #getAttributeValue() <em>Attribute Value</em>}' attribute.
109:          * <!-- begin-user-doc -->
110:          * <!-- end-user-doc -->
111:          *
112:          * @see #getAttributeValue()
113:          * @generated
114:          * @ordered
115:          */
116:         protected Object attributeValue = ATTRIBUTE_VALUE_EDEFAULT;
117:
118:         /**
119:          * <!-- begin-user-doc -->
120:          * <!-- end-user-doc -->
121:          *
122:          * @generated
123:          */
124:         protected VTViewModelElementSelectorImpl() {
125:                 super();
126:         }
127:
128:         /**
129:          * <!-- begin-user-doc -->
130:          * <!-- end-user-doc -->
131:          *
132:          * @generated
133:          */
134:         @Override
135:         protected EClass eStaticClass() {
136:                 return VTViewModelElementPackage.Literals.VIEW_MODEL_ELEMENT_SELECTOR;
137:         }
138:
139:         /**
140:          * <!-- begin-user-doc -->
141:          * <!-- end-user-doc -->
142:          *
143:          * @generated
144:          */
145:         @Override
146:         public EClass getClassType() {
147:•                if (classType != null && classType.eIsProxy()) {
148:                         final InternalEObject oldClassType = (InternalEObject) classType;
149:                         classType = (EClass) eResolveProxy(oldClassType);
150:•                        if (classType != oldClassType) {
151:•                                if (eNotificationRequired()) {
152:                                         eNotify(new ENotificationImpl(this, Notification.RESOLVE,
153:                                                 VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__CLASS_TYPE, oldClassType, classType));
154:                                 }
155:                         }
156:                 }
157:                 return classType;
158:         }
159:
160:         /**
161:          * <!-- begin-user-doc -->
162:          * <!-- end-user-doc -->
163:          *
164:          * @generated
165:          */
166:         public EClass basicGetClassType() {
167:                 return classType;
168:         }
169:
170:         /**
171:          * <!-- begin-user-doc -->
172:          * <!-- end-user-doc -->
173:          *
174:          * @generated
175:          */
176:         @Override
177:         public void setClassType(EClass newClassType) {
178:                 final EClass oldClassType = classType;
179:                 classType = newClassType;
180:•                if (eNotificationRequired()) {
181:                         eNotify(new ENotificationImpl(this, Notification.SET,
182:                                 VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__CLASS_TYPE, oldClassType, classType));
183:                 }
184:         }
185:
186:         /**
187:          * <!-- begin-user-doc -->
188:          * <!-- end-user-doc -->
189:          *
190:          * @generated
191:          */
192:         @Override
193:         public EAttribute getAttribute() {
194:•                if (attribute != null && attribute.eIsProxy()) {
195:                         final InternalEObject oldAttribute = (InternalEObject) attribute;
196:                         attribute = (EAttribute) eResolveProxy(oldAttribute);
197:•                        if (attribute != oldAttribute) {
198:•                                if (eNotificationRequired()) {
199:                                         eNotify(new ENotificationImpl(this, Notification.RESOLVE,
200:                                                 VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE, oldAttribute, attribute));
201:                                 }
202:                         }
203:                 }
204:                 return attribute;
205:         }
206:
207:         /**
208:          * <!-- begin-user-doc -->
209:          * <!-- end-user-doc -->
210:          *
211:          * @generated
212:          */
213:         public EAttribute basicGetAttribute() {
214:                 return attribute;
215:         }
216:
217:         /**
218:          * <!-- begin-user-doc -->
219:          * <!-- end-user-doc -->
220:          *
221:          * @generated
222:          */
223:         @Override
224:         public void setAttribute(EAttribute newAttribute) {
225:                 final EAttribute oldAttribute = attribute;
226:                 attribute = newAttribute;
227:•                if (eNotificationRequired()) {
228:                         eNotify(new ENotificationImpl(this, Notification.SET,
229:                                 VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE, oldAttribute, attribute));
230:                 }
231:         }
232:
233:         /**
234:          * <!-- begin-user-doc -->
235:          * <!-- end-user-doc -->
236:          *
237:          * @generated
238:          */
239:         @Override
240:         public Object getAttributeValue() {
241:                 return attributeValue;
242:         }
243:
244:         /**
245:          * <!-- begin-user-doc -->
246:          * <!-- end-user-doc -->
247:          *
248:          * @generated
249:          */
250:         @Override
251:         public void setAttributeValue(Object newAttributeValue) {
252:                 final Object oldAttributeValue = attributeValue;
253:                 attributeValue = newAttributeValue;
254:•                if (eNotificationRequired()) {
255:                         eNotify(new ENotificationImpl(this, Notification.SET,
256:                                 VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE_VALUE, oldAttributeValue,
257:                                 attributeValue));
258:                 }
259:         }
260:
261:         /**
262:          * <!-- begin-user-doc -->
263:          * <!-- end-user-doc -->
264:          *
265:          * @generated
266:          */
267:         @Override
268:         public boolean isSelectSubclasses() {
269:                 return selectSubclasses;
270:         }
271:
272:         /**
273:          * <!-- begin-user-doc -->
274:          * <!-- end-user-doc -->
275:          *
276:          * @generated
277:          */
278:         @Override
279:         public void setSelectSubclasses(boolean newSelectSubclasses) {
280:                 final boolean oldSelectSubclasses = selectSubclasses;
281:                 selectSubclasses = newSelectSubclasses;
282:•                if (eNotificationRequired()) {
283:                         eNotify(new ENotificationImpl(this, Notification.SET,
284:                                 VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__SELECT_SUBCLASSES, oldSelectSubclasses,
285:                                 selectSubclasses));
286:                 }
287:         }
288:
289:         /**
290:          * <!-- begin-user-doc -->
291:          * <!-- end-user-doc -->
292:          *
293:          * @generated
294:          */
295:         @Override
296:         public Object eGet(int featureID, boolean resolve, boolean coreType) {
297:•                switch (featureID) {
298:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__SELECT_SUBCLASSES:
299:                         return isSelectSubclasses();
300:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__CLASS_TYPE:
301:•                        if (resolve) {
302:                                 return getClassType();
303:                         }
304:                         return basicGetClassType();
305:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE:
306:•                        if (resolve) {
307:                                 return getAttribute();
308:                         }
309:                         return basicGetAttribute();
310:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE_VALUE:
311:                         return getAttributeValue();
312:                 }
313:                 return super.eGet(featureID, resolve, coreType);
314:         }
315:
316:         /**
317:          * <!-- begin-user-doc -->
318:          * <!-- end-user-doc -->
319:          *
320:          * @generated
321:          */
322:         @Override
323:         public void eSet(int featureID, Object newValue) {
324:•                switch (featureID) {
325:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__SELECT_SUBCLASSES:
326:                         setSelectSubclasses((Boolean) newValue);
327:                         return;
328:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__CLASS_TYPE:
329:                         setClassType((EClass) newValue);
330:                         return;
331:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE:
332:                         setAttribute((EAttribute) newValue);
333:                         return;
334:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE_VALUE:
335:                         setAttributeValue(newValue);
336:                         return;
337:                 }
338:                 super.eSet(featureID, newValue);
339:         }
340:
341:         /**
342:          * <!-- begin-user-doc -->
343:          * <!-- end-user-doc -->
344:          *
345:          * @generated
346:          */
347:         @Override
348:         public void eUnset(int featureID) {
349:•                switch (featureID) {
350:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__SELECT_SUBCLASSES:
351:                         setSelectSubclasses(SELECT_SUBCLASSES_EDEFAULT);
352:                         return;
353:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__CLASS_TYPE:
354:                         setClassType((EClass) null);
355:                         return;
356:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE:
357:                         setAttribute((EAttribute) null);
358:                         return;
359:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE_VALUE:
360:                         setAttributeValue(ATTRIBUTE_VALUE_EDEFAULT);
361:                         return;
362:                 }
363:                 super.eUnset(featureID);
364:         }
365:
366:         /**
367:          * <!-- begin-user-doc -->
368:          * <!-- end-user-doc -->
369:          *
370:          * @generated
371:          */
372:         @Override
373:         public boolean eIsSet(int featureID) {
374:•                switch (featureID) {
375:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__SELECT_SUBCLASSES:
376:                         return selectSubclasses != SELECT_SUBCLASSES_EDEFAULT;
377:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__CLASS_TYPE:
378:•                        return classType != null;
379:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE:
380:•                        return attribute != null;
381:                 case VTViewModelElementPackage.VIEW_MODEL_ELEMENT_SELECTOR__ATTRIBUTE_VALUE:
382:•                        return ATTRIBUTE_VALUE_EDEFAULT == null ? attributeValue != null
383:                                 : !ATTRIBUTE_VALUE_EDEFAULT
384:•                                        .equals(attributeValue);
385:                 }
386:                 return super.eIsSet(featureID);
387:         }
388:
389:         /**
390:          * <!-- begin-user-doc -->
391:          * <!-- end-user-doc -->
392:          *
393:          * @generated
394:          */
395:         @Override
396:         public String toString() {
397:•                if (eIsProxy()) {
398:                         return super.toString();
399:                 }
400:
401:                 final StringBuffer result = new StringBuffer(super.toString());
402:                 result.append(" (selectSubclasses: "); //$NON-NLS-1$
403:                 result.append(selectSubclasses);
404:                 result.append(", attributeValue: "); //$NON-NLS-1$
405:                 result.append(attributeValue);
406:                 result.append(')');
407:                 return result.toString();
408:         }
409:
410:         /**
411:          * {@inheritDoc}
412:          *
413:          * @see org.eclipse.emf.ecp.view.template.model.VTStyleSelector#isApplicable(org.eclipse.emf.ecp.view.spi.model.VElement,
414:          * org.eclipse.emf.ecp.view.spi.context.ViewModelContext)
415:          */
416:         @Override
417:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
418:•                if (classType == null) {
419:                         return NOT_APPLICABLE;
420:                 }
421:•                if (selectSubclasses && !classType.isSuperTypeOf(vElement.eClass())) {
422:                         return NOT_APPLICABLE;
423:•                } else if (!selectSubclasses && !classType.equals(vElement.eClass())) {
424:                         return NOT_APPLICABLE;
425:                 }
426:•                if (attribute != null) {
427:                         final Object attrValue = vElement.eGet(attribute);
428:•                        if (attrValue == null) {
429:                                 return NOT_APPLICABLE;
430:                         }
431:•                        if (!attrValue.equals(attributeValue)) {
432:                                 return NOT_APPLICABLE;
433:                         }
434:                         /*
435:                          * a view model element selector with an attribute should be regarded as more specific as a view model
436:                          * element selector without an attribute
437:                          */
438:                         return 6;
439:                 }
440:
441:                 return 5;
442:         }
443: } // VTViewModelElementSelectorImpl