/******************************************************************************* * Copyright (c) 2010-2013, Embraer S.A., Budapest University of Technology and Economics * 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: * Abel Hegedus, Akos Horvath - initial API and implementation *******************************************************************************/ /** */ package hu.bme.mit.massif.simulink.impl; import hu.bme.mit.massif.simulink.InPort; import hu.bme.mit.massif.simulink.MultiConnection; import hu.bme.mit.massif.simulink.SimulinkPackage; import hu.bme.mit.massif.simulink.SingleConnection; 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.ecore.util.EcoreUtil; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Single Connection</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link hu.bme.mit.massif.simulink.impl.SingleConnectionImpl#getParent <em>Parent</em>}</li> * <li>{@link hu.bme.mit.massif.simulink.impl.SingleConnectionImpl#getTo <em>To</em>}</li> * </ul> * </p> * * @generated */ public class SingleConnectionImpl extends ConnectionImpl implements SingleConnection { /** * The cached value of the '{@link #getTo() <em>To</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getTo() * @generated * @ordered */ protected InPort to; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected SingleConnectionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return SimulinkPackage.Literals.SINGLE_CONNECTION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public MultiConnection getParent() { if (eContainerFeatureID() != SimulinkPackage.SINGLE_CONNECTION__PARENT) return null; return (MultiConnection)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetParent(MultiConnection newParent, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newParent, SimulinkPackage.SINGLE_CONNECTION__PARENT, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setParent(MultiConnection newParent) { if (newParent != eInternalContainer() || (eContainerFeatureID() != SimulinkPackage.SINGLE_CONNECTION__PARENT && newParent != null)) { if (EcoreUtil.isAncestor(this, newParent)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newParent != null) msgs = ((InternalEObject)newParent).eInverseAdd(this, SimulinkPackage.MULTI_CONNECTION__CONNECTIONS, MultiConnection.class, msgs); msgs = basicSetParent(newParent, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SimulinkPackage.SINGLE_CONNECTION__PARENT, newParent, newParent)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public InPort getTo() { if (to != null && to.eIsProxy()) { InternalEObject oldTo = (InternalEObject)to; to = (InPort)eResolveProxy(oldTo); if (to != oldTo) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, SimulinkPackage.SINGLE_CONNECTION__TO, oldTo, to)); } } return to; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public InPort basicGetTo() { return to; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTo(InPort newTo, NotificationChain msgs) { InPort oldTo = to; to = newTo; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SimulinkPackage.SINGLE_CONNECTION__TO, oldTo, newTo); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTo(InPort newTo) { if (newTo != to) { NotificationChain msgs = null; if (to != null) msgs = ((InternalEObject)to).eInverseRemove(this, SimulinkPackage.IN_PORT__CONNECTION, InPort.class, msgs); if (newTo != null) msgs = ((InternalEObject)newTo).eInverseAdd(this, SimulinkPackage.IN_PORT__CONNECTION, InPort.class, msgs); msgs = basicSetTo(newTo, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SimulinkPackage.SINGLE_CONNECTION__TO, newTo, newTo)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case SimulinkPackage.SINGLE_CONNECTION__PARENT: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetParent((MultiConnection)otherEnd, msgs); case SimulinkPackage.SINGLE_CONNECTION__TO: if (to != null) msgs = ((InternalEObject)to).eInverseRemove(this, SimulinkPackage.IN_PORT__CONNECTION, InPort.class, msgs); return basicSetTo((InPort)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 SimulinkPackage.SINGLE_CONNECTION__PARENT: return basicSetParent(null, msgs); case SimulinkPackage.SINGLE_CONNECTION__TO: return basicSetTo(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case SimulinkPackage.SINGLE_CONNECTION__PARENT: return eInternalContainer().eInverseRemove(this, SimulinkPackage.MULTI_CONNECTION__CONNECTIONS, MultiConnection.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 SimulinkPackage.SINGLE_CONNECTION__PARENT: return getParent(); case SimulinkPackage.SINGLE_CONNECTION__TO: if (resolve) return getTo(); return basicGetTo(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case SimulinkPackage.SINGLE_CONNECTION__PARENT: setParent((MultiConnection)newValue); return; case SimulinkPackage.SINGLE_CONNECTION__TO: setTo((InPort)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case SimulinkPackage.SINGLE_CONNECTION__PARENT: setParent((MultiConnection)null); return; case SimulinkPackage.SINGLE_CONNECTION__TO: setTo((InPort)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case SimulinkPackage.SINGLE_CONNECTION__PARENT: return getParent() != null; case SimulinkPackage.SINGLE_CONNECTION__TO: return to != null; } return super.eIsSet(featureID); } } //SingleConnectionImpl