/** * Copyright (c) 2011 committers of YAKINDU and others. * 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 * Contributors: * committers of YAKINDU - initial API and implementation * */ package org.yakindu.sct.model.sgraph.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.EObjectContainmentWithInverseEList; import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; import org.yakindu.base.base.impl.NamedElementImpl; import org.yakindu.sct.model.sgraph.Region; import org.yakindu.sct.model.sgraph.SGraphPackage; import org.yakindu.sct.model.sgraph.Transition; import org.yakindu.sct.model.sgraph.Vertex; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Vertex</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.yakindu.sct.model.sgraph.impl.VertexImpl#getParentRegion <em>Parent Region</em>}</li> * <li>{@link org.yakindu.sct.model.sgraph.impl.VertexImpl#getIncomingTransitions <em>Incoming Transitions</em>}</li> * <li>{@link org.yakindu.sct.model.sgraph.impl.VertexImpl#getOutgoingTransitions <em>Outgoing Transitions</em>}</li> * </ul> * * @generated */ public abstract class VertexImpl extends NamedElementImpl implements Vertex { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static final String copyright = "Copyright (c) 2011 committers of YAKINDU and others.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\nContributors:\r\ncommitters of YAKINDU - initial API and implementation\r\n"; /** * The cached value of the '{@link #getIncomingTransitions() <em>Incoming Transitions</em>}' reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getIncomingTransitions() * @generated * @ordered */ protected EList<Transition> incomingTransitions; /** * The cached value of the '{@link #getOutgoingTransitions() <em>Outgoing Transitions</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOutgoingTransitions() * @generated * @ordered */ protected EList<Transition> outgoingTransitions; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected VertexImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return SGraphPackage.Literals.VERTEX; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Region getParentRegion() { if (eContainerFeatureID() != SGraphPackage.VERTEX__PARENT_REGION) return null; return (Region)eContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Region basicGetParentRegion() { if (eContainerFeatureID() != SGraphPackage.VERTEX__PARENT_REGION) return null; return (Region)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetParentRegion(Region newParentRegion, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newParentRegion, SGraphPackage.VERTEX__PARENT_REGION, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setParentRegion(Region newParentRegion) { if (newParentRegion != eInternalContainer() || (eContainerFeatureID() != SGraphPackage.VERTEX__PARENT_REGION && newParentRegion != null)) { if (EcoreUtil.isAncestor(this, newParentRegion)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newParentRegion != null) msgs = ((InternalEObject)newParentRegion).eInverseAdd(this, SGraphPackage.REGION__VERTICES, Region.class, msgs); msgs = basicSetParentRegion(newParentRegion, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SGraphPackage.VERTEX__PARENT_REGION, newParentRegion, newParentRegion)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Transition> getIncomingTransitions() { if (incomingTransitions == null) { incomingTransitions = new EObjectWithInverseResolvingEList<Transition>(Transition.class, this, SGraphPackage.VERTEX__INCOMING_TRANSITIONS, SGraphPackage.TRANSITION__TARGET); } return incomingTransitions; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<Transition> getOutgoingTransitions() { if (outgoingTransitions == null) { outgoingTransitions = new EObjectContainmentWithInverseEList.Resolving<Transition>(Transition.class, this, SGraphPackage.VERTEX__OUTGOING_TRANSITIONS, SGraphPackage.TRANSITION__SOURCE); } return outgoingTransitions; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case SGraphPackage.VERTEX__PARENT_REGION: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetParentRegion((Region)otherEnd, msgs); case SGraphPackage.VERTEX__INCOMING_TRANSITIONS: return ((InternalEList<InternalEObject>)(InternalEList<?>)getIncomingTransitions()).basicAdd(otherEnd, msgs); case SGraphPackage.VERTEX__OUTGOING_TRANSITIONS: return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutgoingTransitions()).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 SGraphPackage.VERTEX__PARENT_REGION: return basicSetParentRegion(null, msgs); case SGraphPackage.VERTEX__INCOMING_TRANSITIONS: return ((InternalEList<?>)getIncomingTransitions()).basicRemove(otherEnd, msgs); case SGraphPackage.VERTEX__OUTGOING_TRANSITIONS: return ((InternalEList<?>)getOutgoingTransitions()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case SGraphPackage.VERTEX__PARENT_REGION: return eInternalContainer().eInverseRemove(this, SGraphPackage.REGION__VERTICES, Region.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case SGraphPackage.VERTEX__PARENT_REGION: if (resolve) return getParentRegion(); return basicGetParentRegion(); case SGraphPackage.VERTEX__INCOMING_TRANSITIONS: return getIncomingTransitions(); case SGraphPackage.VERTEX__OUTGOING_TRANSITIONS: return getOutgoingTransitions(); } 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 SGraphPackage.VERTEX__PARENT_REGION: setParentRegion((Region)newValue); return; case SGraphPackage.VERTEX__INCOMING_TRANSITIONS: getIncomingTransitions().clear(); getIncomingTransitions().addAll((Collection<? extends Transition>)newValue); return; case SGraphPackage.VERTEX__OUTGOING_TRANSITIONS: getOutgoingTransitions().clear(); getOutgoingTransitions().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 SGraphPackage.VERTEX__PARENT_REGION: setParentRegion((Region)null); return; case SGraphPackage.VERTEX__INCOMING_TRANSITIONS: getIncomingTransitions().clear(); return; case SGraphPackage.VERTEX__OUTGOING_TRANSITIONS: getOutgoingTransitions().clear(); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case SGraphPackage.VERTEX__PARENT_REGION: return basicGetParentRegion() != null; case SGraphPackage.VERTEX__INCOMING_TRANSITIONS: return incomingTransitions != null && !incomingTransitions.isEmpty(); case SGraphPackage.VERTEX__OUTGOING_TRANSITIONS: return outgoingTransitions != null && !outgoingTransitions.isEmpty(); } return super.eIsSet(featureID); } } //VertexImpl