/** | |
* Copyright (c) 2020 CEA LIST. | |
* | |
* 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\n\nContributors: | |
* Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr | |
* - Initial API and Implementation | |
*/ | |
package org.eclipse.efm.ecore.formalml.infrastructure.impl; | |
import java.util.Collection; | |
import org.eclipse.efm.ecore.formalml.common.impl.NamedElementImpl; | |
import org.eclipse.efm.ecore.formalml.infrastructure.ComProtocol; | |
import org.eclipse.efm.ecore.formalml.infrastructure.Connector; | |
import org.eclipse.efm.ecore.formalml.infrastructure.ConnectorEnd; | |
import org.eclipse.efm.ecore.formalml.infrastructure.InfrastructurePackage; | |
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.EObjectContainmentEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Connector</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* </p> | |
* <ul> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.ConnectorImpl#getProtocol <em>Protocol</em>}</li> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.ConnectorImpl#getConnectorEnd <em>Connector End</em>}</li> | |
* </ul> | |
* | |
* @generated | |
*/ | |
public class ConnectorImpl extends NamedElementImpl implements Connector { | |
/** | |
* The cached value of the '{@link #getProtocol() <em>Protocol</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getProtocol() | |
* @generated | |
* @ordered | |
*/ | |
protected ComProtocol protocol; | |
/** | |
* The cached value of the '{@link #getConnectorEnd() <em>Connector End</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getConnectorEnd() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<ConnectorEnd> connectorEnd; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected ConnectorImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return InfrastructurePackage.Literals.CONNECTOR; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public ComProtocol getProtocol() { | |
return protocol; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetProtocol(ComProtocol newProtocol, NotificationChain msgs) { | |
ComProtocol oldProtocol = protocol; | |
protocol = newProtocol; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InfrastructurePackage.CONNECTOR__PROTOCOL, oldProtocol, newProtocol); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void setProtocol(ComProtocol newProtocol) { | |
if (newProtocol != protocol) { | |
NotificationChain msgs = null; | |
if (protocol != null) | |
msgs = ((InternalEObject)protocol).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.CONNECTOR__PROTOCOL, null, msgs); | |
if (newProtocol != null) | |
msgs = ((InternalEObject)newProtocol).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.CONNECTOR__PROTOCOL, null, msgs); | |
msgs = basicSetProtocol(newProtocol, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, InfrastructurePackage.CONNECTOR__PROTOCOL, newProtocol, newProtocol)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public EList<ConnectorEnd> getConnectorEnd() { | |
if (connectorEnd == null) { | |
connectorEnd = new EObjectContainmentEList<ConnectorEnd>(ConnectorEnd.class, this, InfrastructurePackage.CONNECTOR__CONNECTOR_END); | |
} | |
return connectorEnd; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case InfrastructurePackage.CONNECTOR__PROTOCOL: | |
return basicSetProtocol(null, msgs); | |
case InfrastructurePackage.CONNECTOR__CONNECTOR_END: | |
return ((InternalEList<?>)getConnectorEnd()).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 InfrastructurePackage.CONNECTOR__PROTOCOL: | |
return getProtocol(); | |
case InfrastructurePackage.CONNECTOR__CONNECTOR_END: | |
return getConnectorEnd(); | |
} | |
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 InfrastructurePackage.CONNECTOR__PROTOCOL: | |
setProtocol((ComProtocol)newValue); | |
return; | |
case InfrastructurePackage.CONNECTOR__CONNECTOR_END: | |
getConnectorEnd().clear(); | |
getConnectorEnd().addAll((Collection<? extends ConnectorEnd>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.CONNECTOR__PROTOCOL: | |
setProtocol((ComProtocol)null); | |
return; | |
case InfrastructurePackage.CONNECTOR__CONNECTOR_END: | |
getConnectorEnd().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.CONNECTOR__PROTOCOL: | |
return protocol != null; | |
case InfrastructurePackage.CONNECTOR__CONNECTOR_END: | |
return connectorEnd != null && !connectorEnd.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
} //ConnectorImpl |