1
2
3
4
5
6 package org.mod4j.crossx.mm.crossx.impl;
7
8 import java.util.Collection;
9
10 import org.eclipse.emf.common.notify.Notification;
11 import org.eclipse.emf.common.notify.NotificationChain;
12
13 import org.eclipse.emf.common.util.EList;
14
15 import org.eclipse.emf.ecore.EClass;
16 import org.eclipse.emf.ecore.InternalEObject;
17
18 import org.eclipse.emf.ecore.impl.ENotificationImpl;
19 import org.eclipse.emf.ecore.impl.EObjectImpl;
20
21 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
22 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
23 import org.eclipse.emf.ecore.util.EcoreUtil;
24 import org.eclipse.emf.ecore.util.InternalEList;
25
26 import org.mod4j.crossx.mm.crossx.CrossxPackage;
27 import org.mod4j.crossx.mm.crossx.ModelInfo;
28 import org.mod4j.crossx.mm.crossx.Symbol;
29 import org.mod4j.crossx.mm.crossx.SymbolProperty;
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 public class SymbolImpl extends EObjectImpl implements Symbol {
50
51
52
53
54
55
56
57
58 protected static final String NAME_EDEFAULT = null;
59
60
61
62
63
64
65
66
67
68 protected String name = NAME_EDEFAULT;
69
70
71
72
73
74
75
76
77
78 protected static final String TYPE_EDEFAULT = null;
79
80
81
82
83
84
85
86
87
88 protected String type = TYPE_EDEFAULT;
89
90
91
92
93
94
95
96
97
98 protected EList<SymbolProperty> properties;
99
100
101
102
103
104
105
106
107
108 protected EList<Symbol> subSymbols;
109
110
111
112
113
114
115 protected SymbolImpl() {
116 super();
117 }
118
119
120
121
122
123
124 @Override
125 protected EClass eStaticClass() {
126 return CrossxPackage.Literals.SYMBOL;
127 }
128
129
130
131
132
133
134 public String getName() {
135 return name;
136 }
137
138
139
140
141
142
143 public void setName(String newName) {
144 String oldName = name;
145 name = newName;
146 if (eNotificationRequired())
147 eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__NAME, oldName, name));
148 }
149
150
151
152
153
154
155 public String getType() {
156 return type;
157 }
158
159
160
161
162
163
164 public void setType(String newType) {
165 String oldType = type;
166 type = newType;
167 if (eNotificationRequired())
168 eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__TYPE, oldType, type));
169 }
170
171
172
173
174
175
176 public EList<SymbolProperty> getProperties() {
177 if (properties == null) {
178 properties = new EObjectContainmentEList<SymbolProperty>(SymbolProperty.class, this, CrossxPackage.SYMBOL__PROPERTIES);
179 }
180 return properties;
181 }
182
183
184
185
186
187
188 public EList<Symbol> getSubSymbols() {
189 if (subSymbols == null) {
190 subSymbols = new EObjectContainmentWithInverseEList<Symbol>(Symbol.class, this, CrossxPackage.SYMBOL__SUB_SYMBOLS, CrossxPackage.SYMBOL__PARENT);
191 }
192 return subSymbols;
193 }
194
195
196
197
198
199
200 public ModelInfo getOwner() {
201 if (eContainerFeatureID() != CrossxPackage.SYMBOL__OWNER) return null;
202 return (ModelInfo)eContainer();
203 }
204
205
206
207
208
209
210 public NotificationChain basicSetOwner(ModelInfo newOwner, NotificationChain msgs) {
211 msgs = eBasicSetContainer((InternalEObject)newOwner, CrossxPackage.SYMBOL__OWNER, msgs);
212 return msgs;
213 }
214
215
216
217
218
219
220 public void setOwner(ModelInfo newOwner) {
221 if (newOwner != eInternalContainer() || (eContainerFeatureID() != CrossxPackage.SYMBOL__OWNER && newOwner != null)) {
222 if (EcoreUtil.isAncestor(this, newOwner))
223 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
224 NotificationChain msgs = null;
225 if (eInternalContainer() != null)
226 msgs = eBasicRemoveFromContainer(msgs);
227 if (newOwner != null)
228 msgs = ((InternalEObject)newOwner).eInverseAdd(this, CrossxPackage.MODEL_INFO__SYMBOLS, ModelInfo.class, msgs);
229 msgs = basicSetOwner(newOwner, msgs);
230 if (msgs != null) msgs.dispatch();
231 }
232 else if (eNotificationRequired())
233 eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__OWNER, newOwner, newOwner));
234 }
235
236
237
238
239
240
241 public Symbol getParent() {
242 if (eContainerFeatureID() != CrossxPackage.SYMBOL__PARENT) return null;
243 return (Symbol)eContainer();
244 }
245
246
247
248
249
250
251 public NotificationChain basicSetParent(Symbol newParent, NotificationChain msgs) {
252 msgs = eBasicSetContainer((InternalEObject)newParent, CrossxPackage.SYMBOL__PARENT, msgs);
253 return msgs;
254 }
255
256
257
258
259
260
261 public void setParent(Symbol newParent) {
262 if (newParent != eInternalContainer() || (eContainerFeatureID() != CrossxPackage.SYMBOL__PARENT && newParent != null)) {
263 if (EcoreUtil.isAncestor(this, newParent))
264 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
265 NotificationChain msgs = null;
266 if (eInternalContainer() != null)
267 msgs = eBasicRemoveFromContainer(msgs);
268 if (newParent != null)
269 msgs = ((InternalEObject)newParent).eInverseAdd(this, CrossxPackage.SYMBOL__SUB_SYMBOLS, Symbol.class, msgs);
270 msgs = basicSetParent(newParent, msgs);
271 if (msgs != null) msgs.dispatch();
272 }
273 else if (eNotificationRequired())
274 eNotify(new ENotificationImpl(this, Notification.SET, CrossxPackage.SYMBOL__PARENT, newParent, newParent));
275 }
276
277
278
279
280
281
282 @SuppressWarnings("unchecked")
283 @Override
284 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
285 switch (featureID) {
286 case CrossxPackage.SYMBOL__SUB_SYMBOLS:
287 return ((InternalEList<InternalEObject>)(InternalEList<?>)getSubSymbols()).basicAdd(otherEnd, msgs);
288 case CrossxPackage.SYMBOL__OWNER:
289 if (eInternalContainer() != null)
290 msgs = eBasicRemoveFromContainer(msgs);
291 return basicSetOwner((ModelInfo)otherEnd, msgs);
292 case CrossxPackage.SYMBOL__PARENT:
293 if (eInternalContainer() != null)
294 msgs = eBasicRemoveFromContainer(msgs);
295 return basicSetParent((Symbol)otherEnd, msgs);
296 }
297 return super.eInverseAdd(otherEnd, featureID, msgs);
298 }
299
300
301
302
303
304
305 @Override
306 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
307 switch (featureID) {
308 case CrossxPackage.SYMBOL__PROPERTIES:
309 return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs);
310 case CrossxPackage.SYMBOL__SUB_SYMBOLS:
311 return ((InternalEList<?>)getSubSymbols()).basicRemove(otherEnd, msgs);
312 case CrossxPackage.SYMBOL__OWNER:
313 return basicSetOwner(null, msgs);
314 case CrossxPackage.SYMBOL__PARENT:
315 return basicSetParent(null, msgs);
316 }
317 return super.eInverseRemove(otherEnd, featureID, msgs);
318 }
319
320
321
322
323
324
325 @Override
326 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
327 switch (eContainerFeatureID()) {
328 case CrossxPackage.SYMBOL__OWNER:
329 return eInternalContainer().eInverseRemove(this, CrossxPackage.MODEL_INFO__SYMBOLS, ModelInfo.class, msgs);
330 case CrossxPackage.SYMBOL__PARENT:
331 return eInternalContainer().eInverseRemove(this, CrossxPackage.SYMBOL__SUB_SYMBOLS, Symbol.class, msgs);
332 }
333 return super.eBasicRemoveFromContainerFeature(msgs);
334 }
335
336
337
338
339
340
341 @Override
342 public Object eGet(int featureID, boolean resolve, boolean coreType) {
343 switch (featureID) {
344 case CrossxPackage.SYMBOL__NAME:
345 return getName();
346 case CrossxPackage.SYMBOL__TYPE:
347 return getType();
348 case CrossxPackage.SYMBOL__PROPERTIES:
349 return getProperties();
350 case CrossxPackage.SYMBOL__SUB_SYMBOLS:
351 return getSubSymbols();
352 case CrossxPackage.SYMBOL__OWNER:
353 return getOwner();
354 case CrossxPackage.SYMBOL__PARENT:
355 return getParent();
356 }
357 return super.eGet(featureID, resolve, coreType);
358 }
359
360
361
362
363
364
365 @SuppressWarnings("unchecked")
366 @Override
367 public void eSet(int featureID, Object newValue) {
368 switch (featureID) {
369 case CrossxPackage.SYMBOL__NAME:
370 setName((String)newValue);
371 return;
372 case CrossxPackage.SYMBOL__TYPE:
373 setType((String)newValue);
374 return;
375 case CrossxPackage.SYMBOL__PROPERTIES:
376 getProperties().clear();
377 getProperties().addAll((Collection<? extends SymbolProperty>)newValue);
378 return;
379 case CrossxPackage.SYMBOL__SUB_SYMBOLS:
380 getSubSymbols().clear();
381 getSubSymbols().addAll((Collection<? extends Symbol>)newValue);
382 return;
383 case CrossxPackage.SYMBOL__OWNER:
384 setOwner((ModelInfo)newValue);
385 return;
386 case CrossxPackage.SYMBOL__PARENT:
387 setParent((Symbol)newValue);
388 return;
389 }
390 super.eSet(featureID, newValue);
391 }
392
393
394
395
396
397
398 @Override
399 public void eUnset(int featureID) {
400 switch (featureID) {
401 case CrossxPackage.SYMBOL__NAME:
402 setName(NAME_EDEFAULT);
403 return;
404 case CrossxPackage.SYMBOL__TYPE:
405 setType(TYPE_EDEFAULT);
406 return;
407 case CrossxPackage.SYMBOL__PROPERTIES:
408 getProperties().clear();
409 return;
410 case CrossxPackage.SYMBOL__SUB_SYMBOLS:
411 getSubSymbols().clear();
412 return;
413 case CrossxPackage.SYMBOL__OWNER:
414 setOwner((ModelInfo)null);
415 return;
416 case CrossxPackage.SYMBOL__PARENT:
417 setParent((Symbol)null);
418 return;
419 }
420 super.eUnset(featureID);
421 }
422
423
424
425
426
427
428 @Override
429 public boolean eIsSet(int featureID) {
430 switch (featureID) {
431 case CrossxPackage.SYMBOL__NAME:
432 return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
433 case CrossxPackage.SYMBOL__TYPE:
434 return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
435 case CrossxPackage.SYMBOL__PROPERTIES:
436 return properties != null && !properties.isEmpty();
437 case CrossxPackage.SYMBOL__SUB_SYMBOLS:
438 return subSymbols != null && !subSymbols.isEmpty();
439 case CrossxPackage.SYMBOL__OWNER:
440 return getOwner() != null;
441 case CrossxPackage.SYMBOL__PARENT:
442 return getParent() != null;
443 }
444 return super.eIsSet(featureID);
445 }
446
447
448
449
450
451
452 @Override
453 public String toString() {
454 if (eIsProxy()) return super.toString();
455
456 StringBuffer result = new StringBuffer(super.toString());
457 result.append(" (name: ");
458 result.append(name);
459 result.append(", type: ");
460 result.append(type);
461 result.append(')');
462 return result.toString();
463 }
464
465 }