/** | |
* 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.AbstractElementImpl; | |
import org.eclipse.efm.ecore.formalml.infrastructure.ChannelDirection; | |
import org.eclipse.efm.ecore.formalml.infrastructure.ComPoint; | |
import org.eclipse.efm.ecore.formalml.infrastructure.ComProtocol; | |
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 End</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* </p> | |
* <ul> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.ConnectorEndImpl#getDirection <em>Direction</em>}</li> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.ConnectorEndImpl#getProtocol <em>Protocol</em>}</li> | |
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.ConnectorEndImpl#getPoints <em>Points</em>}</li> | |
* </ul> | |
* | |
* @generated | |
*/ | |
public class ConnectorEndImpl extends AbstractElementImpl implements ConnectorEnd { | |
/** | |
* 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 #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 #getPoints() <em>Points</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getPoints() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<ComPoint> points; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected ConnectorEndImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return InfrastructurePackage.Literals.CONNECTOR_END; | |
} | |
/** | |
* <!-- 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.CONNECTOR_END__DIRECTION, oldDirection, direction)); | |
} | |
/** | |
* <!-- 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_END__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_END__PROTOCOL, null, msgs); | |
if (newProtocol != null) | |
msgs = ((InternalEObject)newProtocol).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.CONNECTOR_END__PROTOCOL, null, msgs); | |
msgs = basicSetProtocol(newProtocol, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, InfrastructurePackage.CONNECTOR_END__PROTOCOL, newProtocol, newProtocol)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public EList<ComPoint> getPoints() { | |
if (points == null) { | |
points = new EObjectContainmentEList<ComPoint>(ComPoint.class, this, InfrastructurePackage.CONNECTOR_END__POINTS); | |
} | |
return points; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case InfrastructurePackage.CONNECTOR_END__PROTOCOL: | |
return basicSetProtocol(null, msgs); | |
case InfrastructurePackage.CONNECTOR_END__POINTS: | |
return ((InternalEList<?>)getPoints()).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_END__DIRECTION: | |
return getDirection(); | |
case InfrastructurePackage.CONNECTOR_END__PROTOCOL: | |
return getProtocol(); | |
case InfrastructurePackage.CONNECTOR_END__POINTS: | |
return getPoints(); | |
} | |
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_END__DIRECTION: | |
setDirection((ChannelDirection)newValue); | |
return; | |
case InfrastructurePackage.CONNECTOR_END__PROTOCOL: | |
setProtocol((ComProtocol)newValue); | |
return; | |
case InfrastructurePackage.CONNECTOR_END__POINTS: | |
getPoints().clear(); | |
getPoints().addAll((Collection<? extends ComPoint>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.CONNECTOR_END__DIRECTION: | |
setDirection(DIRECTION_EDEFAULT); | |
return; | |
case InfrastructurePackage.CONNECTOR_END__PROTOCOL: | |
setProtocol((ComProtocol)null); | |
return; | |
case InfrastructurePackage.CONNECTOR_END__POINTS: | |
getPoints().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case InfrastructurePackage.CONNECTOR_END__DIRECTION: | |
return direction != DIRECTION_EDEFAULT; | |
case InfrastructurePackage.CONNECTOR_END__PROTOCOL: | |
return protocol != null; | |
case InfrastructurePackage.CONNECTOR_END__POINTS: | |
return points != null && !points.isEmpty(); | |
} | |
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(); | |
} | |
} //ConnectorEndImpl |