001 /**
002 * <copyright>
003 * </copyright>
004 *
005 * $Id$
006 */
007 package com.hammurapi.flow.impl;
008
009 import com.hammurapi.config.Factory;
010 import com.hammurapi.config.Named;
011 import com.hammurapi.config.impl.NamedObjectDefinitionImpl;
012
013 import com.hammurapi.flow.Flow;
014 import com.hammurapi.flow.FlowPackage;
015 import com.hammurapi.flow.Pin;
016 import com.hammurapi.flow.Transition;
017
018 import java.util.Collection;
019 import org.eclipse.emf.common.notify.Notification;
020
021 import org.eclipse.emf.common.notify.NotificationChain;
022 import org.eclipse.emf.common.util.EList;
023 import org.eclipse.emf.ecore.EClass;
024 import org.eclipse.emf.ecore.InternalEObject;
025
026 import org.eclipse.emf.ecore.impl.ENotificationImpl;
027 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
028 import org.eclipse.emf.ecore.util.EcoreUtil;
029 import org.eclipse.emf.ecore.util.InternalEList;
030
031 /**
032 * <!-- begin-user-doc -->
033 * An implementation of the model object '<em><b>Transition</b></em>'.
034 * <!-- end-user-doc -->
035 * <p>
036 * The following features are implemented:
037 * <ul>
038 * <li>{@link com.hammurapi.flow.impl.TransitionImpl#getFlow <em>Flow</em>}</li>
039 * <li>{@link com.hammurapi.flow.impl.TransitionImpl#getViewConfig <em>View Config</em>}</li>
040 * <li>{@link com.hammurapi.flow.impl.TransitionImpl#getFromPin <em>From Pin</em>}</li>
041 * <li>{@link com.hammurapi.flow.impl.TransitionImpl#getToPin <em>To Pin</em>}</li>
042 * <li>{@link com.hammurapi.flow.impl.TransitionImpl#getFromKey <em>From Key</em>}</li>
043 * <li>{@link com.hammurapi.flow.impl.TransitionImpl#getToKey <em>To Key</em>}</li>
044 * </ul>
045 * </p>
046 *
047 * @generated
048 */
049 public class TransitionImpl extends NamedObjectDefinitionImpl implements Transition {
050 /**
051 * The cached value of the '{@link #getViewConfig() <em>View Config</em>}' containment reference list.
052 * <!-- begin-user-doc -->
053 * <!-- end-user-doc -->
054 * @see #getViewConfig()
055 * @generated
056 * @ordered
057 */
058 protected EList<Named> viewConfig;
059
060 /**
061 * The cached value of the '{@link #getFromPin() <em>From Pin</em>}' reference.
062 * <!-- begin-user-doc -->
063 * <!-- end-user-doc -->
064 * @see #getFromPin()
065 * @generated
066 * @ordered
067 */
068 protected Pin fromPin;
069
070 /**
071 * The cached value of the '{@link #getToPin() <em>To Pin</em>}' reference.
072 * <!-- begin-user-doc -->
073 * <!-- end-user-doc -->
074 * @see #getToPin()
075 * @generated
076 * @ordered
077 */
078 protected Pin toPin;
079
080 /**
081 * The cached value of the '{@link #getFromKey() <em>From Key</em>}' containment reference.
082 * <!-- begin-user-doc -->
083 * <!-- end-user-doc -->
084 * @see #getFromKey()
085 * @generated
086 * @ordered
087 */
088 protected Factory fromKey;
089
090 /**
091 * The cached value of the '{@link #getToKey() <em>To Key</em>}' containment reference.
092 * <!-- begin-user-doc -->
093 * <!-- end-user-doc -->
094 * @see #getToKey()
095 * @generated
096 * @ordered
097 */
098 protected Factory toKey;
099
100 /**
101 * <!-- begin-user-doc -->
102 * <!-- end-user-doc -->
103 * @generated
104 */
105 protected TransitionImpl() {
106 super();
107 }
108
109 /**
110 * <!-- begin-user-doc -->
111 * <!-- end-user-doc -->
112 * @generated
113 */
114 @Override
115 protected EClass eStaticClass() {
116 return FlowPackage.Literals.TRANSITION;
117 }
118
119 /**
120 * <!-- begin-user-doc -->
121 * <!-- end-user-doc -->
122 * @generated
123 */
124 public Flow getFlow() {
125 if (eContainerFeatureID() != FlowPackage.TRANSITION__FLOW) return null;
126 return (Flow)eContainer();
127 }
128
129 /**
130 * <!-- begin-user-doc -->
131 * <!-- end-user-doc -->
132 * @generated
133 */
134 public NotificationChain basicSetFlow(Flow newFlow, NotificationChain msgs) {
135 msgs = eBasicSetContainer((InternalEObject)newFlow, FlowPackage.TRANSITION__FLOW, msgs);
136 return msgs;
137 }
138
139 /**
140 * <!-- begin-user-doc -->
141 * <!-- end-user-doc -->
142 * @generated
143 */
144 public void setFlow(Flow newFlow) {
145 if (newFlow != eInternalContainer() || (eContainerFeatureID() != FlowPackage.TRANSITION__FLOW && newFlow != null)) {
146 if (EcoreUtil.isAncestor(this, newFlow))
147 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
148 NotificationChain msgs = null;
149 if (eInternalContainer() != null)
150 msgs = eBasicRemoveFromContainer(msgs);
151 if (newFlow != null)
152 msgs = ((InternalEObject)newFlow).eInverseAdd(this, FlowPackage.FLOW__FLOW_ELEMENT, Flow.class, msgs);
153 msgs = basicSetFlow(newFlow, msgs);
154 if (msgs != null) msgs.dispatch();
155 }
156 else if (eNotificationRequired())
157 eNotify(new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__FLOW, newFlow, newFlow));
158 }
159
160 /**
161 * <!-- begin-user-doc -->
162 * <!-- end-user-doc -->
163 * @generated
164 */
165 public EList<Named> getViewConfig() {
166 if (viewConfig == null) {
167 viewConfig = new EObjectContainmentEList<Named>(Named.class, this, FlowPackage.TRANSITION__VIEW_CONFIG);
168 }
169 return viewConfig;
170 }
171
172 /**
173 * <!-- begin-user-doc -->
174 * <!-- end-user-doc -->
175 * @generated
176 */
177 public Pin getFromPin() {
178 if (fromPin != null && fromPin.eIsProxy()) {
179 InternalEObject oldFromPin = (InternalEObject)fromPin;
180 fromPin = (Pin)eResolveProxy(oldFromPin);
181 if (fromPin != oldFromPin) {
182 if (eNotificationRequired())
183 eNotify(new ENotificationImpl(this, Notification.RESOLVE, FlowPackage.TRANSITION__FROM_PIN, oldFromPin, fromPin));
184 }
185 }
186 return fromPin;
187 }
188
189 /**
190 * <!-- begin-user-doc -->
191 * <!-- end-user-doc -->
192 * @generated
193 */
194 public Pin basicGetFromPin() {
195 return fromPin;
196 }
197
198 /**
199 * <!-- begin-user-doc -->
200 * <!-- end-user-doc -->
201 * @generated
202 */
203 public NotificationChain basicSetFromPin(Pin newFromPin, NotificationChain msgs) {
204 Pin oldFromPin = fromPin;
205 fromPin = newFromPin;
206 if (eNotificationRequired()) {
207 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__FROM_PIN, oldFromPin, newFromPin);
208 if (msgs == null) msgs = notification; else msgs.add(notification);
209 }
210 return msgs;
211 }
212
213 /**
214 * <!-- begin-user-doc -->
215 * <!-- end-user-doc -->
216 * @generated
217 */
218 public void setFromPin(Pin newFromPin) {
219 if (newFromPin != fromPin) {
220 NotificationChain msgs = null;
221 if (fromPin != null)
222 msgs = ((InternalEObject)fromPin).eInverseRemove(this, FlowPackage.PIN__OUTPUT, Pin.class, msgs);
223 if (newFromPin != null)
224 msgs = ((InternalEObject)newFromPin).eInverseAdd(this, FlowPackage.PIN__OUTPUT, Pin.class, msgs);
225 msgs = basicSetFromPin(newFromPin, msgs);
226 if (msgs != null) msgs.dispatch();
227 }
228 else if (eNotificationRequired())
229 eNotify(new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__FROM_PIN, newFromPin, newFromPin));
230 }
231
232 /**
233 * <!-- begin-user-doc -->
234 * <!-- end-user-doc -->
235 * @generated
236 */
237 public Pin getToPin() {
238 if (toPin != null && toPin.eIsProxy()) {
239 InternalEObject oldToPin = (InternalEObject)toPin;
240 toPin = (Pin)eResolveProxy(oldToPin);
241 if (toPin != oldToPin) {
242 if (eNotificationRequired())
243 eNotify(new ENotificationImpl(this, Notification.RESOLVE, FlowPackage.TRANSITION__TO_PIN, oldToPin, toPin));
244 }
245 }
246 return toPin;
247 }
248
249 /**
250 * <!-- begin-user-doc -->
251 * <!-- end-user-doc -->
252 * @generated
253 */
254 public Pin basicGetToPin() {
255 return toPin;
256 }
257
258 /**
259 * <!-- begin-user-doc -->
260 * <!-- end-user-doc -->
261 * @generated
262 */
263 public NotificationChain basicSetToPin(Pin newToPin, NotificationChain msgs) {
264 Pin oldToPin = toPin;
265 toPin = newToPin;
266 if (eNotificationRequired()) {
267 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__TO_PIN, oldToPin, newToPin);
268 if (msgs == null) msgs = notification; else msgs.add(notification);
269 }
270 return msgs;
271 }
272
273 /**
274 * <!-- begin-user-doc -->
275 * <!-- end-user-doc -->
276 * @generated
277 */
278 public void setToPin(Pin newToPin) {
279 if (newToPin != toPin) {
280 NotificationChain msgs = null;
281 if (toPin != null)
282 msgs = ((InternalEObject)toPin).eInverseRemove(this, FlowPackage.PIN__INPUT, Pin.class, msgs);
283 if (newToPin != null)
284 msgs = ((InternalEObject)newToPin).eInverseAdd(this, FlowPackage.PIN__INPUT, Pin.class, msgs);
285 msgs = basicSetToPin(newToPin, msgs);
286 if (msgs != null) msgs.dispatch();
287 }
288 else if (eNotificationRequired())
289 eNotify(new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__TO_PIN, newToPin, newToPin));
290 }
291
292 /**
293 * <!-- begin-user-doc -->
294 * <!-- end-user-doc -->
295 * @generated
296 */
297 public Factory getFromKey() {
298 return fromKey;
299 }
300
301 /**
302 * <!-- begin-user-doc -->
303 * <!-- end-user-doc -->
304 * @generated
305 */
306 public NotificationChain basicSetFromKey(Factory newFromKey, NotificationChain msgs) {
307 Factory oldFromKey = fromKey;
308 fromKey = newFromKey;
309 if (eNotificationRequired()) {
310 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__FROM_KEY, oldFromKey, newFromKey);
311 if (msgs == null) msgs = notification; else msgs.add(notification);
312 }
313 return msgs;
314 }
315
316 /**
317 * <!-- begin-user-doc -->
318 * <!-- end-user-doc -->
319 * @generated
320 */
321 public void setFromKey(Factory newFromKey) {
322 if (newFromKey != fromKey) {
323 NotificationChain msgs = null;
324 if (fromKey != null)
325 msgs = ((InternalEObject)fromKey).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FlowPackage.TRANSITION__FROM_KEY, null, msgs);
326 if (newFromKey != null)
327 msgs = ((InternalEObject)newFromKey).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - FlowPackage.TRANSITION__FROM_KEY, null, msgs);
328 msgs = basicSetFromKey(newFromKey, msgs);
329 if (msgs != null) msgs.dispatch();
330 }
331 else if (eNotificationRequired())
332 eNotify(new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__FROM_KEY, newFromKey, newFromKey));
333 }
334
335 /**
336 * <!-- begin-user-doc -->
337 * <!-- end-user-doc -->
338 * @generated
339 */
340 public Factory getToKey() {
341 return toKey;
342 }
343
344 /**
345 * <!-- begin-user-doc -->
346 * <!-- end-user-doc -->
347 * @generated
348 */
349 public NotificationChain basicSetToKey(Factory newToKey, NotificationChain msgs) {
350 Factory oldToKey = toKey;
351 toKey = newToKey;
352 if (eNotificationRequired()) {
353 ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__TO_KEY, oldToKey, newToKey);
354 if (msgs == null) msgs = notification; else msgs.add(notification);
355 }
356 return msgs;
357 }
358
359 /**
360 * <!-- begin-user-doc -->
361 * <!-- end-user-doc -->
362 * @generated
363 */
364 public void setToKey(Factory newToKey) {
365 if (newToKey != toKey) {
366 NotificationChain msgs = null;
367 if (toKey != null)
368 msgs = ((InternalEObject)toKey).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FlowPackage.TRANSITION__TO_KEY, null, msgs);
369 if (newToKey != null)
370 msgs = ((InternalEObject)newToKey).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - FlowPackage.TRANSITION__TO_KEY, null, msgs);
371 msgs = basicSetToKey(newToKey, msgs);
372 if (msgs != null) msgs.dispatch();
373 }
374 else if (eNotificationRequired())
375 eNotify(new ENotificationImpl(this, Notification.SET, FlowPackage.TRANSITION__TO_KEY, newToKey, newToKey));
376 }
377
378 /**
379 * <!-- begin-user-doc -->
380 * <!-- end-user-doc -->
381 * @generated
382 */
383 @Override
384 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
385 switch (featureID) {
386 case FlowPackage.TRANSITION__FLOW:
387 if (eInternalContainer() != null)
388 msgs = eBasicRemoveFromContainer(msgs);
389 return basicSetFlow((Flow)otherEnd, msgs);
390 case FlowPackage.TRANSITION__FROM_PIN:
391 if (fromPin != null)
392 msgs = ((InternalEObject)fromPin).eInverseRemove(this, FlowPackage.PIN__OUTPUT, Pin.class, msgs);
393 return basicSetFromPin((Pin)otherEnd, msgs);
394 case FlowPackage.TRANSITION__TO_PIN:
395 if (toPin != null)
396 msgs = ((InternalEObject)toPin).eInverseRemove(this, FlowPackage.PIN__INPUT, Pin.class, msgs);
397 return basicSetToPin((Pin)otherEnd, msgs);
398 }
399 return super.eInverseAdd(otherEnd, featureID, msgs);
400 }
401
402 /**
403 * <!-- begin-user-doc -->
404 * <!-- end-user-doc -->
405 * @generated
406 */
407 @Override
408 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
409 switch (featureID) {
410 case FlowPackage.TRANSITION__FLOW:
411 return basicSetFlow(null, msgs);
412 case FlowPackage.TRANSITION__VIEW_CONFIG:
413 return ((InternalEList<?>)getViewConfig()).basicRemove(otherEnd, msgs);
414 case FlowPackage.TRANSITION__FROM_PIN:
415 return basicSetFromPin(null, msgs);
416 case FlowPackage.TRANSITION__TO_PIN:
417 return basicSetToPin(null, msgs);
418 case FlowPackage.TRANSITION__FROM_KEY:
419 return basicSetFromKey(null, msgs);
420 case FlowPackage.TRANSITION__TO_KEY:
421 return basicSetToKey(null, msgs);
422 }
423 return super.eInverseRemove(otherEnd, featureID, msgs);
424 }
425
426 /**
427 * <!-- begin-user-doc -->
428 * <!-- end-user-doc -->
429 * @generated
430 */
431 @Override
432 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
433 switch (eContainerFeatureID()) {
434 case FlowPackage.TRANSITION__FLOW:
435 return eInternalContainer().eInverseRemove(this, FlowPackage.FLOW__FLOW_ELEMENT, Flow.class, msgs);
436 }
437 return super.eBasicRemoveFromContainerFeature(msgs);
438 }
439
440 /**
441 * <!-- begin-user-doc -->
442 * <!-- end-user-doc -->
443 * @generated
444 */
445 @Override
446 public Object eGet(int featureID, boolean resolve, boolean coreType) {
447 switch (featureID) {
448 case FlowPackage.TRANSITION__FLOW:
449 return getFlow();
450 case FlowPackage.TRANSITION__VIEW_CONFIG:
451 return getViewConfig();
452 case FlowPackage.TRANSITION__FROM_PIN:
453 if (resolve) return getFromPin();
454 return basicGetFromPin();
455 case FlowPackage.TRANSITION__TO_PIN:
456 if (resolve) return getToPin();
457 return basicGetToPin();
458 case FlowPackage.TRANSITION__FROM_KEY:
459 return getFromKey();
460 case FlowPackage.TRANSITION__TO_KEY:
461 return getToKey();
462 }
463 return super.eGet(featureID, resolve, coreType);
464 }
465
466 /**
467 * <!-- begin-user-doc -->
468 * <!-- end-user-doc -->
469 * @generated
470 */
471 @SuppressWarnings("unchecked")
472 @Override
473 public void eSet(int featureID, Object newValue) {
474 switch (featureID) {
475 case FlowPackage.TRANSITION__FLOW:
476 setFlow((Flow)newValue);
477 return;
478 case FlowPackage.TRANSITION__VIEW_CONFIG:
479 getViewConfig().clear();
480 getViewConfig().addAll((Collection<? extends Named>)newValue);
481 return;
482 case FlowPackage.TRANSITION__FROM_PIN:
483 setFromPin((Pin)newValue);
484 return;
485 case FlowPackage.TRANSITION__TO_PIN:
486 setToPin((Pin)newValue);
487 return;
488 case FlowPackage.TRANSITION__FROM_KEY:
489 setFromKey((Factory)newValue);
490 return;
491 case FlowPackage.TRANSITION__TO_KEY:
492 setToKey((Factory)newValue);
493 return;
494 }
495 super.eSet(featureID, newValue);
496 }
497
498 /**
499 * <!-- begin-user-doc -->
500 * <!-- end-user-doc -->
501 * @generated
502 */
503 @Override
504 public void eUnset(int featureID) {
505 switch (featureID) {
506 case FlowPackage.TRANSITION__FLOW:
507 setFlow((Flow)null);
508 return;
509 case FlowPackage.TRANSITION__VIEW_CONFIG:
510 getViewConfig().clear();
511 return;
512 case FlowPackage.TRANSITION__FROM_PIN:
513 setFromPin((Pin)null);
514 return;
515 case FlowPackage.TRANSITION__TO_PIN:
516 setToPin((Pin)null);
517 return;
518 case FlowPackage.TRANSITION__FROM_KEY:
519 setFromKey((Factory)null);
520 return;
521 case FlowPackage.TRANSITION__TO_KEY:
522 setToKey((Factory)null);
523 return;
524 }
525 super.eUnset(featureID);
526 }
527
528 /**
529 * <!-- begin-user-doc -->
530 * <!-- end-user-doc -->
531 * @generated
532 */
533 @Override
534 public boolean eIsSet(int featureID) {
535 switch (featureID) {
536 case FlowPackage.TRANSITION__FLOW:
537 return getFlow() != null;
538 case FlowPackage.TRANSITION__VIEW_CONFIG:
539 return viewConfig != null && !viewConfig.isEmpty();
540 case FlowPackage.TRANSITION__FROM_PIN:
541 return fromPin != null;
542 case FlowPackage.TRANSITION__TO_PIN:
543 return toPin != null;
544 case FlowPackage.TRANSITION__FROM_KEY:
545 return fromKey != null;
546 case FlowPackage.TRANSITION__TO_KEY:
547 return toKey != null;
548 }
549 return super.eIsSet(featureID);
550 }
551
552 } //TransitionImpl