/******************************************************************************* * 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.Connection; import hu.bme.mit.massif.simulink.OutPort; import hu.bme.mit.massif.simulink.SimulinkPackage; 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>Connection</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link hu.bme.mit.massif.simulink.impl.ConnectionImpl#getFrom <em>From</em>}</li> * <li>{@link hu.bme.mit.massif.simulink.impl.ConnectionImpl#getLineName <em>Line Name</em>}</li> * </ul> * </p> * * @generated */ public abstract class ConnectionImpl extends SimulinkElementImpl implements Connection { /** * The default value of the '{@link #getLineName() <em>Line Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLineName() * @generated * @ordered */ protected static final String LINE_NAME_EDEFAULT = null; /** * The cached value of the '{@link #getLineName() <em>Line Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getLineName() * @generated * @ordered */ protected String lineName = LINE_NAME_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ConnectionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return SimulinkPackage.Literals.CONNECTION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public OutPort getFrom() { if (eContainerFeatureID() != SimulinkPackage.CONNECTION__FROM) return null; return (OutPort)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetFrom(OutPort newFrom, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newFrom, SimulinkPackage.CONNECTION__FROM, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setFrom(OutPort newFrom) { if (newFrom != eInternalContainer() || (eContainerFeatureID() != SimulinkPackage.CONNECTION__FROM && newFrom != null)) { if (EcoreUtil.isAncestor(this, newFrom)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newFrom != null) msgs = ((InternalEObject)newFrom).eInverseAdd(this, SimulinkPackage.OUT_PORT__CONNECTION, OutPort.class, msgs); msgs = basicSetFrom(newFrom, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SimulinkPackage.CONNECTION__FROM, newFrom, newFrom)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getLineName() { return lineName; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setLineName(String newLineName) { String oldLineName = lineName; lineName = newLineName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SimulinkPackage.CONNECTION__LINE_NAME, oldLineName, lineName)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case SimulinkPackage.CONNECTION__FROM: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetFrom((OutPort)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.CONNECTION__FROM: return basicSetFrom(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.CONNECTION__FROM: return eInternalContainer().eInverseRemove(this, SimulinkPackage.OUT_PORT__CONNECTION, OutPort.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.CONNECTION__FROM: return getFrom(); case SimulinkPackage.CONNECTION__LINE_NAME: return getLineName(); } 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.CONNECTION__FROM: setFrom((OutPort)newValue); return; case SimulinkPackage.CONNECTION__LINE_NAME: setLineName((String)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case SimulinkPackage.CONNECTION__FROM: setFrom((OutPort)null); return; case SimulinkPackage.CONNECTION__LINE_NAME: setLineName(LINE_NAME_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case SimulinkPackage.CONNECTION__FROM: return getFrom() != null; case SimulinkPackage.CONNECTION__LINE_NAME: return LINE_NAME_EDEFAULT == null ? lineName != null : !LINE_NAME_EDEFAULT.equals(lineName); } 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(" (lineName: "); result.append(lineName); result.append(')'); return result.toString(); } } //ConnectionImpl