/** | |
* 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.InfrastructurePackage; | |
import org.eclipse.efm.ecore.formalml.infrastructure.Route; | |
import org.eclipse.efm.ecore.formalml.infrastructure.Signal; | |
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.EObjectResolvingEList; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Route</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* </p> | |
* <ul> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.RouteImpl#getSignals <em>Signals</em>}</li> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.RouteImpl#getProtocol <em>Protocol</em>}</li> | |
* </ul> | |
* | |
* @generated | |
*/ | |
public class RouteImpl extends NamedElementImpl implements Route { | |
/** | |
* The cached value of the '{@link #getSignals() <em>Signals</em>}' reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getSignals() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Signal> signals; | |
/** | |
* 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; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected RouteImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return InfrastructurePackage.Literals.ROUTE; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public EList<Signal> getSignals() { | |
if (signals == null) { | |
signals = new EObjectResolvingEList<Signal>(Signal.class, this, InfrastructurePackage.ROUTE__SIGNALS); | |
} | |
return signals; | |
} | |
/** | |
* <!-- 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.ROUTE__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.ROUTE__PROTOCOL, null, msgs); | |
if (newProtocol != null) | |
msgs = ((InternalEObject)newProtocol).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.ROUTE__PROTOCOL, null, msgs); | |
msgs = basicSetProtocol(newProtocol, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, InfrastructurePackage.ROUTE__PROTOCOL, newProtocol, newProtocol)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case InfrastructurePackage.ROUTE__PROTOCOL: | |
return basicSetProtocol(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 InfrastructurePackage.ROUTE__SIGNALS: | |
return getSignals(); | |
case InfrastructurePackage.ROUTE__PROTOCOL: | |
return getProtocol(); | |
} | |
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.ROUTE__SIGNALS: | |
getSignals().clear(); | |
getSignals().addAll((Collection<? extends Signal>)newValue); | |
return; | |
case InfrastructurePackage.ROUTE__PROTOCOL: | |
setProtocol((ComProtocol)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.ROUTE__SIGNALS: | |
getSignals().clear(); | |
return; | |
case InfrastructurePackage.ROUTE__PROTOCOL: | |
setProtocol((ComProtocol)null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.ROUTE__SIGNALS: | |
return signals != null && !signals.isEmpty(); | |
case InfrastructurePackage.ROUTE__PROTOCOL: | |
return protocol != null; | |
} | |
return super.eIsSet(featureID); | |
} | |
} //RouteImpl |