/** | |
* 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.infrastructure.ChannelDirection; | |
import org.eclipse.efm.ecore.formalml.infrastructure.InfrastructurePackage; | |
import org.eclipse.efm.ecore.formalml.infrastructure.ParameterSet; | |
import org.eclipse.efm.ecore.formalml.infrastructure.Port; | |
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.EObjectContainmentEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Port</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* </p> | |
* <ul> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.PortImpl#getDirection <em>Direction</em>}</li> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.PortImpl#getSignal <em>Signal</em>}</li> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.PortImpl#getParameterSet <em>Parameter Set</em>}</li> | |
* </ul> | |
* | |
* @generated | |
*/ | |
public class PortImpl extends PropertyDefinitionImpl implements Port { | |
/** | |
* The default value of the '{@link #getDirection() <em>Direction</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getDirection() | |
* @generated | |
* @ordered | |
*/ | |
protected static final ChannelDirection DIRECTION_EDEFAULT = ChannelDirection.INOUT; | |
/** | |
* The cached value of the '{@link #getDirection() <em>Direction</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getDirection() | |
* @generated | |
* @ordered | |
*/ | |
protected ChannelDirection direction = DIRECTION_EDEFAULT; | |
/** | |
* The cached value of the '{@link #getSignal() <em>Signal</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getSignal() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Signal> signal; | |
/** | |
* The cached value of the '{@link #getParameterSet() <em>Parameter Set</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getParameterSet() | |
* @generated | |
* @ordered | |
*/ | |
protected ParameterSet parameterSet; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected PortImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return InfrastructurePackage.Literals.PORT; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public ChannelDirection getDirection() { | |
return direction; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void setDirection(ChannelDirection newDirection) { | |
ChannelDirection oldDirection = direction; | |
direction = newDirection == null ? DIRECTION_EDEFAULT : newDirection; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, InfrastructurePackage.PORT__DIRECTION, oldDirection, direction)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public EList<Signal> getSignal() { | |
if (signal == null) { | |
signal = new EObjectContainmentEList<Signal>(Signal.class, this, InfrastructurePackage.PORT__SIGNAL); | |
} | |
return signal; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public ParameterSet getParameterSet() { | |
return parameterSet; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetParameterSet(ParameterSet newParameterSet, NotificationChain msgs) { | |
ParameterSet oldParameterSet = parameterSet; | |
parameterSet = newParameterSet; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InfrastructurePackage.PORT__PARAMETER_SET, oldParameterSet, newParameterSet); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void setParameterSet(ParameterSet newParameterSet) { | |
if (newParameterSet != parameterSet) { | |
NotificationChain msgs = null; | |
if (parameterSet != null) | |
msgs = ((InternalEObject)parameterSet).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.PORT__PARAMETER_SET, null, msgs); | |
if (newParameterSet != null) | |
msgs = ((InternalEObject)newParameterSet).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.PORT__PARAMETER_SET, null, msgs); | |
msgs = basicSetParameterSet(newParameterSet, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, InfrastructurePackage.PORT__PARAMETER_SET, newParameterSet, newParameterSet)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case InfrastructurePackage.PORT__SIGNAL: | |
return ((InternalEList<?>)getSignal()).basicRemove(otherEnd, msgs); | |
case InfrastructurePackage.PORT__PARAMETER_SET: | |
return basicSetParameterSet(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.PORT__DIRECTION: | |
return getDirection(); | |
case InfrastructurePackage.PORT__SIGNAL: | |
return getSignal(); | |
case InfrastructurePackage.PORT__PARAMETER_SET: | |
return getParameterSet(); | |
} | |
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.PORT__DIRECTION: | |
setDirection((ChannelDirection)newValue); | |
return; | |
case InfrastructurePackage.PORT__SIGNAL: | |
getSignal().clear(); | |
getSignal().addAll((Collection<? extends Signal>)newValue); | |
return; | |
case InfrastructurePackage.PORT__PARAMETER_SET: | |
setParameterSet((ParameterSet)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.PORT__DIRECTION: | |
setDirection(DIRECTION_EDEFAULT); | |
return; | |
case InfrastructurePackage.PORT__SIGNAL: | |
getSignal().clear(); | |
return; | |
case InfrastructurePackage.PORT__PARAMETER_SET: | |
setParameterSet((ParameterSet)null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.PORT__DIRECTION: | |
return direction != DIRECTION_EDEFAULT; | |
case InfrastructurePackage.PORT__SIGNAL: | |
return signal != null && !signal.isEmpty(); | |
case InfrastructurePackage.PORT__PARAMETER_SET: | |
return parameterSet != null; | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public String toString() { | |
if (eIsProxy()) return super.toString(); | |
StringBuilder result = new StringBuilder(super.toString()); | |
result.append(" (direction: "); | |
result.append(direction); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //PortImpl |