blob: 18968b4116599db128420c65ee4b86c9a85eb5f1 [file] [log] [blame]
/**
* * Copyright (c) 2021 The University of York.
* *
* * This program and the accompanying materials are made
* * available under the terms of the Eclipse Public License 2.0
* * which is available at https://www.eclipse.org/legal/epl-2.0/
* *
* * SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.epsilon.sirius.widget.examples.statemachine.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.epsilon.sirius.widget.examples.statemachine.State;
import org.eclipse.epsilon.sirius.widget.examples.statemachine.StatemachinePackage;
import org.eclipse.epsilon.sirius.widget.examples.statemachine.Transition;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>State</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.epsilon.sirius.widget.examples.statemachine.impl.StateImpl#getAction <em>Action</em>}</li>
* <li>{@link org.eclipse.epsilon.sirius.widget.examples.statemachine.impl.StateImpl#getOutgoing <em>Outgoing</em>}</li>
* <li>{@link org.eclipse.epsilon.sirius.widget.examples.statemachine.impl.StateImpl#getIncoming <em>Incoming</em>}</li>
* </ul>
*
* @generated
*/
public class StateImpl extends NamedElementImpl implements State {
/**
* The default value of the '{@link #getAction() <em>Action</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAction()
* @generated
* @ordered
*/
protected static final String ACTION_EDEFAULT = null;
/**
* The cached value of the '{@link #getAction() <em>Action</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAction()
* @generated
* @ordered
*/
protected String action = ACTION_EDEFAULT;
/**
* The cached value of the '{@link #getOutgoing() <em>Outgoing</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOutgoing()
* @generated
* @ordered
*/
protected EList<Transition> outgoing;
/**
* The cached value of the '{@link #getIncoming() <em>Incoming</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIncoming()
* @generated
* @ordered
*/
protected EList<Transition> incoming;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected StateImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return StatemachinePackage.Literals.STATE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getAction() {
return action;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAction(String newAction) {
String oldAction = action;
action = newAction;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.STATE__ACTION, oldAction, action));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Transition> getOutgoing() {
if (outgoing == null) {
outgoing = new EObjectWithInverseResolvingEList<Transition>(Transition.class, this, StatemachinePackage.STATE__OUTGOING, StatemachinePackage.TRANSITION__FROM);
}
return outgoing;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Transition> getIncoming() {
if (incoming == null) {
incoming = new EObjectWithInverseResolvingEList<Transition>(Transition.class, this, StatemachinePackage.STATE__INCOMING, StatemachinePackage.TRANSITION__TO);
}
return incoming;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case StatemachinePackage.STATE__OUTGOING:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutgoing()).basicAdd(otherEnd, msgs);
case StatemachinePackage.STATE__INCOMING:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getIncoming()).basicAdd(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 StatemachinePackage.STATE__OUTGOING:
return ((InternalEList<?>)getOutgoing()).basicRemove(otherEnd, msgs);
case StatemachinePackage.STATE__INCOMING:
return ((InternalEList<?>)getIncoming()).basicRemove(otherEnd, 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 StatemachinePackage.STATE__ACTION:
return getAction();
case StatemachinePackage.STATE__OUTGOING:
return getOutgoing();
case StatemachinePackage.STATE__INCOMING:
return getIncoming();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case StatemachinePackage.STATE__ACTION:
setAction((String)newValue);
return;
case StatemachinePackage.STATE__OUTGOING:
getOutgoing().clear();
getOutgoing().addAll((Collection<? extends Transition>)newValue);
return;
case StatemachinePackage.STATE__INCOMING:
getIncoming().clear();
getIncoming().addAll((Collection<? extends Transition>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case StatemachinePackage.STATE__ACTION:
setAction(ACTION_EDEFAULT);
return;
case StatemachinePackage.STATE__OUTGOING:
getOutgoing().clear();
return;
case StatemachinePackage.STATE__INCOMING:
getIncoming().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case StatemachinePackage.STATE__ACTION:
return ACTION_EDEFAULT == null ? action != null : !ACTION_EDEFAULT.equals(action);
case StatemachinePackage.STATE__OUTGOING:
return outgoing != null && !outgoing.isEmpty();
case StatemachinePackage.STATE__INCOMING:
return incoming != null && !incoming.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuilder result = new StringBuilder(super.toString());
result.append(" (action: ");
result.append(action);
result.append(')');
return result.toString();
}
} //StateImpl