Skip to content

Package: VTAnnotationSelectorImpl

VTAnnotationSelectorImpl

nameinstructionbranchcomplexitylinemethod
VTAnnotationSelectorImpl()
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%
eGet(int, boolean, boolean)
M: 6 C: 8
57%
M: 1 C: 2
67%
M: 1 C: 2
67%
M: 1 C: 3
75%
M: 0 C: 1
100%
eIsSet(int)
M: 20 C: 22
52%
M: 7 C: 8
53%
M: 5 C: 4
44%
M: 1 C: 3
75%
M: 0 C: 1
100%
eSet(int, Object)
M: 5 C: 12
71%
M: 1 C: 2
67%
M: 1 C: 2
67%
M: 2 C: 5
71%
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: 14 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getKey()
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%
getValue()
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%
isApplicable(VElement, ViewModelContext)
M: 0 C: 59
100%
M: 0 C: 16
100%
M: 0 C: 9
100%
M: 0 C: 16
100%
M: 0 C: 1
100%
setKey(String)
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
setValue(String)
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
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-2018 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: * Johannes Faltermeier - initial API and implementation
13: */
14: package org.eclipse.emf.ecp.view.template.selector.annotation.model.impl;
15:
16: import org.eclipse.emf.common.notify.Notification;
17: import org.eclipse.emf.ecore.EClass;
18: import org.eclipse.emf.ecore.impl.ENotificationImpl;
19: import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
20: import org.eclipse.emf.ecp.view.spi.context.ViewModelContext;
21: import org.eclipse.emf.ecp.view.spi.model.VAttachment;
22: import org.eclipse.emf.ecp.view.spi.model.VElement;
23: import org.eclipse.emf.ecp.view.template.selector.annotation.model.VTAnnotationPackage;
24: import org.eclipse.emf.ecp.view.template.selector.annotation.model.VTAnnotationSelector;
25: import org.eclipse.emf.emfforms.spi.view.annotation.model.VAnnotation;
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: * </p>
34: * <ul>
35: * <li>{@link org.eclipse.emf.ecp.view.template.selector.annotation.model.impl.VTAnnotationSelectorImpl#getKey
36: * <em>Key</em>}</li>
37: * <li>{@link org.eclipse.emf.ecp.view.template.selector.annotation.model.impl.VTAnnotationSelectorImpl#getValue
38: * <em>Value</em>}</li>
39: * </ul>
40: *
41: * @generated
42: */
43: public class VTAnnotationSelectorImpl extends MinimalEObjectImpl.Container
44:         implements VTAnnotationSelector {
45:         /**
46:          * The default value of the '{@link #getKey() <em>Key</em>}' attribute.
47:          * <!-- begin-user-doc -->
48:          * <!-- end-user-doc -->
49:          *
50:          * @see #getKey()
51:          * @generated
52:          * @ordered
53:          */
54:         protected static final String KEY_EDEFAULT = null;
55:
56:         /**
57:          * The cached value of the '{@link #getKey() <em>Key</em>}' attribute.
58:          * <!-- begin-user-doc -->
59:          * <!-- end-user-doc -->
60:          *
61:          * @see #getKey()
62:          * @generated
63:          * @ordered
64:          */
65:         protected String key = KEY_EDEFAULT;
66:
67:         /**
68:          * The default value of the '{@link #getValue() <em>Value</em>}' attribute.
69:          * <!-- begin-user-doc -->
70:          * <!-- end-user-doc -->
71:          *
72:          * @see #getValue()
73:          * @generated
74:          * @ordered
75:          */
76:         protected static final String VALUE_EDEFAULT = null;
77:
78:         /**
79:          * The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
80:          * <!-- begin-user-doc -->
81:          * <!-- end-user-doc -->
82:          *
83:          * @see #getValue()
84:          * @generated
85:          * @ordered
86:          */
87:         protected String value = VALUE_EDEFAULT;
88:
89:         /**
90:          * <!-- begin-user-doc -->
91:          * <!-- end-user-doc -->
92:          *
93:          * @generated
94:          */
95:         protected VTAnnotationSelectorImpl() {
96:                 super();
97:         }
98:
99:         /**
100:          * <!-- begin-user-doc -->
101:          * <!-- end-user-doc -->
102:          *
103:          * @generated
104:          */
105:         @Override
106:         protected EClass eStaticClass() {
107:                 return VTAnnotationPackage.Literals.ANNOTATION_SELECTOR;
108:         }
109:
110:         /**
111:          * <!-- begin-user-doc -->
112:          * <!-- end-user-doc -->
113:          *
114:          * @generated
115:          */
116:         @Override
117:         public String getKey() {
118:                 return key;
119:         }
120:
121:         /**
122:          * <!-- begin-user-doc -->
123:          * <!-- end-user-doc -->
124:          *
125:          * @generated
126:          */
127:         @Override
128:         public void setKey(String newKey) {
129:                 final String oldKey = key;
130:                 key = newKey;
131:•                if (eNotificationRequired()) {
132:                         eNotify(new ENotificationImpl(this, Notification.SET, VTAnnotationPackage.ANNOTATION_SELECTOR__KEY, oldKey,
133:                                 key));
134:                 }
135:         }
136:
137:         /**
138:          * <!-- begin-user-doc -->
139:          * <!-- end-user-doc -->
140:          *
141:          * @generated
142:          */
143:         @Override
144:         public String getValue() {
145:                 return value;
146:         }
147:
148:         /**
149:          * <!-- begin-user-doc -->
150:          * <!-- end-user-doc -->
151:          *
152:          * @generated
153:          */
154:         @Override
155:         public void setValue(String newValue) {
156:                 final String oldValue = value;
157:                 value = newValue;
158:•                if (eNotificationRequired()) {
159:                         eNotify(new ENotificationImpl(this, Notification.SET, VTAnnotationPackage.ANNOTATION_SELECTOR__VALUE,
160:                                 oldValue, value));
161:                 }
162:         }
163:
164:         /**
165:          * <!-- begin-user-doc -->
166:          * <!-- end-user-doc -->
167:          *
168:          * @generated
169:          */
170:         @Override
171:         public Object eGet(int featureID, boolean resolve, boolean coreType) {
172:•                switch (featureID) {
173:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__KEY:
174:                         return getKey();
175:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__VALUE:
176:                         return getValue();
177:                 }
178:                 return super.eGet(featureID, resolve, coreType);
179:         }
180:
181:         /**
182:          * <!-- begin-user-doc -->
183:          * <!-- end-user-doc -->
184:          *
185:          * @generated
186:          */
187:         @Override
188:         public void eSet(int featureID, Object newValue) {
189:•                switch (featureID) {
190:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__KEY:
191:                         setKey((String) newValue);
192:                         return;
193:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__VALUE:
194:                         setValue((String) newValue);
195:                         return;
196:                 }
197:                 super.eSet(featureID, newValue);
198:         }
199:
200:         /**
201:          * <!-- begin-user-doc -->
202:          * <!-- end-user-doc -->
203:          *
204:          * @generated
205:          */
206:         @Override
207:         public void eUnset(int featureID) {
208:•                switch (featureID) {
209:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__KEY:
210:                         setKey(KEY_EDEFAULT);
211:                         return;
212:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__VALUE:
213:                         setValue(VALUE_EDEFAULT);
214:                         return;
215:                 }
216:                 super.eUnset(featureID);
217:         }
218:
219:         /**
220:          * <!-- begin-user-doc -->
221:          * <!-- end-user-doc -->
222:          *
223:          * @generated
224:          */
225:         @Override
226:         public boolean eIsSet(int featureID) {
227:•                switch (featureID) {
228:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__KEY:
229:•                        return KEY_EDEFAULT == null ? key != null : !KEY_EDEFAULT.equals(key);
230:                 case VTAnnotationPackage.ANNOTATION_SELECTOR__VALUE:
231:•                        return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
232:                 }
233:                 return super.eIsSet(featureID);
234:         }
235:
236:         /**
237:          * <!-- begin-user-doc -->
238:          * <!-- end-user-doc -->
239:          *
240:          * @generated
241:          */
242:         @Override
243:         public String toString() {
244:•                if (eIsProxy()) {
245:                         return super.toString();
246:                 }
247:
248:                 final StringBuffer result = new StringBuffer(super.toString());
249:                 result.append(" (key: "); //$NON-NLS-1$
250:                 result.append(key);
251:                 result.append(", value: "); //$NON-NLS-1$
252:                 result.append(value);
253:                 result.append(')');
254:                 return result.toString();
255:         }
256:
257:         @Override
258:         public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
259:•                for (final VAttachment vAttachment : vElement.getAttachments()) {
260:•                        if (!VAnnotation.class.isInstance(vAttachment)) {
261:                                 continue;
262:                         }
263:                         final VAnnotation annotation = VAnnotation.class.cast(vAttachment);
264:•                        if (getKey() == null) {
265:•                                if (annotation.getKey() != null) {
266:                                         continue;
267:                                 }
268:                         } else {
269:•                                if (!getKey().equals(annotation.getKey())) {
270:                                         continue;
271:                                 }
272:                         }
273:                         /* matching keys */
274:•                        if (getValue() == null) {
275:•                                if (annotation.getValue() != null) {
276:                                         return NOT_APPLICABLE;
277:                                 }
278:                         } else {
279:•                                if (!getValue().equals(annotation.getValue())) {
280:                                         return NOT_APPLICABLE;
281:                                 }
282:                         }
283:                         /* matching key value */
284:                         return 15;
285:                 }
286:                 return NOT_APPLICABLE;
287:         }
288:
289: } // VTAnnotationInHierarchySelectorImpl