/*******************************************************************************
* 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.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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>In Port</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link hu.bme.mit.massif.simulink.impl.InPortImpl#getConnection <em>Connection</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class InPortImpl extends PortImpl implements InPort {
/**
* The cached value of the '{@link #getConnection() <em>Connection</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getConnection()
* @generated
* @ordered
*/
protected SingleConnection connection;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected InPortImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return SimulinkPackage.Literals.IN_PORT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SingleConnection getConnection() {
if (connection != null && connection.eIsProxy()) {
InternalEObject oldConnection = (InternalEObject)connection;
connection = (SingleConnection)eResolveProxy(oldConnection);
if (connection != oldConnection) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, SimulinkPackage.IN_PORT__CONNECTION, oldConnection, connection));
}
}
return connection;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SingleConnection basicGetConnection() {
return connection;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetConnection(SingleConnection newConnection, NotificationChain msgs) {
SingleConnection oldConnection = connection;
connection = newConnection;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SimulinkPackage.IN_PORT__CONNECTION, oldConnection, newConnection);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setConnection(SingleConnection newConnection) {
if (newConnection != connection) {
NotificationChain msgs = null;
if (connection != null)
msgs = ((InternalEObject)connection).eInverseRemove(this, SimulinkPackage.SINGLE_CONNECTION__TO, SingleConnection.class, msgs);
if (newConnection != null)
msgs = ((InternalEObject)newConnection).eInverseAdd(this, SimulinkPackage.SINGLE_CONNECTION__TO, SingleConnection.class, msgs);
msgs = basicSetConnection(newConnection, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, SimulinkPackage.IN_PORT__CONNECTION, newConnection, newConnection));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case SimulinkPackage.IN_PORT__CONNECTION:
if (connection != null)
msgs = ((InternalEObject)connection).eInverseRemove(this, SimulinkPackage.SINGLE_CONNECTION__TO, SingleConnection.class, msgs);
return basicSetConnection((SingleConnection)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.IN_PORT__CONNECTION:
return basicSetConnection(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 SimulinkPackage.IN_PORT__CONNECTION:
if (resolve) return getConnection();
return basicGetConnection();
}
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.IN_PORT__CONNECTION:
setConnection((SingleConnection)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case SimulinkPackage.IN_PORT__CONNECTION:
setConnection((SingleConnection)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case SimulinkPackage.IN_PORT__CONNECTION:
return connection != null;
}
return super.eIsSet(featureID);
}
} //InPortImpl