/**
* <copyright> Copyright (c) 2008-2009 Jonas Helming, Maximilian Koegel. All rights reserved. This program and the
* accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html </copyright>
*/
package org.eclipse.emf.emfstore.client.test.model.state.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.emfstore.client.test.model.impl.UnicaseModelElementImpl;
import org.eclipse.emf.emfstore.client.test.model.state.StateNode;
import org.eclipse.emf.emfstore.client.test.model.state.StatePackage;
import org.eclipse.emf.emfstore.client.test.model.state.Transition;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Transition</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.emfstore.client.test.model.state.impl.TransitionImpl#getCondition <em>Condition</em>}</li>
* <li>{@link org.eclipse.emf.emfstore.client.test.model.state.impl.TransitionImpl#getSource <em>Source</em>}</li>
* <li>{@link org.eclipse.emf.emfstore.client.test.model.state.impl.TransitionImpl#getTarget <em>Target</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class TransitionImpl extends UnicaseModelElementImpl implements Transition {
/**
* The default value of the '{@link #getCondition() <em>Condition</em>}' attribute. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getCondition()
* @generated
* @ordered
*/
protected static final String CONDITION_EDEFAULT = "";
/**
* The cached value of the '{@link #getCondition() <em>Condition</em>}' attribute. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getCondition()
* @generated
* @ordered
*/
protected String condition = CONDITION_EDEFAULT;
/**
* The cached value of the '{@link #getSource() <em>Source</em>}' reference. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getSource()
* @generated
* @ordered
*/
protected StateNode source;
/**
* The cached value of the '{@link #getTarget() <em>Target</em>}' reference. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getTarget()
* @generated
* @ordered
*/
protected StateNode target;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected TransitionImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return StatePackage.Literals.TRANSITION;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public String getCondition() {
return condition;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setCondition(String newCondition) {
String oldCondition = condition;
condition = newCondition;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StatePackage.TRANSITION__CONDITION, oldCondition,
condition));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public StateNode getSource() {
if (source != null && source.eIsProxy()) {
InternalEObject oldSource = (InternalEObject) source;
source = (StateNode) eResolveProxy(oldSource);
if (source != oldSource) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, StatePackage.TRANSITION__SOURCE,
oldSource, source));
}
}
return source;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public StateNode basicGetSource() {
return source;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetSource(StateNode newSource, NotificationChain msgs) {
StateNode oldSource = source;
source = newSource;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
StatePackage.TRANSITION__SOURCE, oldSource, newSource);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setSource(StateNode newSource) {
if (newSource != source) {
NotificationChain msgs = null;
if (source != null)
msgs = ((InternalEObject) source).eInverseRemove(this, StatePackage.STATE_NODE__OUTGOING_TRANSITIONS,
StateNode.class, msgs);
if (newSource != null)
msgs = ((InternalEObject) newSource).eInverseAdd(this, StatePackage.STATE_NODE__OUTGOING_TRANSITIONS,
StateNode.class, msgs);
msgs = basicSetSource(newSource, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StatePackage.TRANSITION__SOURCE, newSource, newSource));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public StateNode getTarget() {
if (target != null && target.eIsProxy()) {
InternalEObject oldTarget = (InternalEObject) target;
target = (StateNode) eResolveProxy(oldTarget);
if (target != oldTarget) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, StatePackage.TRANSITION__TARGET,
oldTarget, target));
}
}
return target;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public StateNode basicGetTarget() {
return target;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetTarget(StateNode newTarget, NotificationChain msgs) {
StateNode oldTarget = target;
target = newTarget;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
StatePackage.TRANSITION__TARGET, oldTarget, newTarget);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setTarget(StateNode newTarget) {
if (newTarget != target) {
NotificationChain msgs = null;
if (target != null)
msgs = ((InternalEObject) target).eInverseRemove(this, StatePackage.STATE_NODE__INCOMING_TRANSITIONS,
StateNode.class, msgs);
if (newTarget != null)
msgs = ((InternalEObject) newTarget).eInverseAdd(this, StatePackage.STATE_NODE__INCOMING_TRANSITIONS,
StateNode.class, msgs);
msgs = basicSetTarget(newTarget, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StatePackage.TRANSITION__TARGET, newTarget, newTarget));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case StatePackage.TRANSITION__SOURCE:
if (source != null)
msgs = ((InternalEObject) source).eInverseRemove(this, StatePackage.STATE_NODE__OUTGOING_TRANSITIONS,
StateNode.class, msgs);
return basicSetSource((StateNode) otherEnd, msgs);
case StatePackage.TRANSITION__TARGET:
if (target != null)
msgs = ((InternalEObject) target).eInverseRemove(this, StatePackage.STATE_NODE__INCOMING_TRANSITIONS,
StateNode.class, msgs);
return basicSetTarget((StateNode) otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case StatePackage.TRANSITION__SOURCE:
return basicSetSource(null, msgs);
case StatePackage.TRANSITION__TARGET:
return basicSetTarget(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case StatePackage.TRANSITION__CONDITION:
return getCondition();
case StatePackage.TRANSITION__SOURCE:
if (resolve)
return getSource();
return basicGetSource();
case StatePackage.TRANSITION__TARGET:
if (resolve)
return getTarget();
return basicGetTarget();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case StatePackage.TRANSITION__CONDITION:
setCondition((String) newValue);
return;
case StatePackage.TRANSITION__SOURCE:
setSource((StateNode) newValue);
return;
case StatePackage.TRANSITION__TARGET:
setTarget((StateNode) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case StatePackage.TRANSITION__CONDITION:
setCondition(CONDITION_EDEFAULT);
return;
case StatePackage.TRANSITION__SOURCE:
setSource((StateNode) null);
return;
case StatePackage.TRANSITION__TARGET:
setTarget((StateNode) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case StatePackage.TRANSITION__CONDITION:
return CONDITION_EDEFAULT == null ? condition != null : !CONDITION_EDEFAULT.equals(condition);
case StatePackage.TRANSITION__SOURCE:
return source != null;
case StatePackage.TRANSITION__TARGET:
return target != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy())
return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (condition: ");
result.append(condition);
result.append(')');
return result.toString();
}
} // TransitionImpl