/**
*/
package ua.ansymo.hintco.impl;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicEList;
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.EcoreUtil;
import ua.ansymo.hintco.DecompositionPortAdaptation;
import ua.ansymo.hintco.HintcoPackage;
import ua.ansymo.hintco.IDed;
import ua.ansymo.hintco.PortAdaptation;
import ua.ansymo.hintco.PortInstance;
import ua.ansymo.hintco.UnitInstance;
/**
*
* An implementation of the model object 'Port Instance'.
*
*
* The following features are implemented:
*
*
* - {@link ua.ansymo.hintco.impl.PortInstanceImpl#getIdentifier Identifier}
* - {@link ua.ansymo.hintco.impl.PortInstanceImpl#getUnit Unit}
* - {@link ua.ansymo.hintco.impl.PortInstanceImpl#getAdaptation Adaptation}
*
*
* @generated
*/
public abstract class PortInstanceImpl extends PrecendenceNodeImpl implements PortInstance {
/**
* The default value of the '{@link #getIdentifier() Identifier}' attribute.
*
*
* @see #getIdentifier()
* @generated
* @ordered
*/
protected static final String IDENTIFIER_EDEFAULT = null;
/**
* The cached value of the '{@link #getIdentifier() Identifier}' attribute.
*
*
* @see #getIdentifier()
* @generated
* @ordered
*/
protected String identifier = IDENTIFIER_EDEFAULT;
/**
* The cached value of the '{@link #getAdaptation() Adaptation}' containment reference.
*
*
* @see #getAdaptation()
* @generated
* @ordered
*/
protected PortAdaptation adaptation;
/**
*
*
* @generated
*/
protected PortInstanceImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return HintcoPackage.Literals.PORT_INSTANCE;
}
/**
*
*
* @generated
*/
public String getIdentifier() {
return identifier;
}
/**
*
*
* @generated
*/
public void setIdentifier(String newIdentifier) {
String oldIdentifier = identifier;
identifier = newIdentifier;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__IDENTIFIER, oldIdentifier, identifier));
}
/**
*
*
* @generated
*/
public UnitInstance getUnit() {
if (eContainerFeatureID() != HintcoPackage.PORT_INSTANCE__UNIT) return null;
return (UnitInstance)eContainer();
}
/**
*
*
* @generated
*/
public UnitInstance basicGetUnit() {
if (eContainerFeatureID() != HintcoPackage.PORT_INSTANCE__UNIT) return null;
return (UnitInstance)eInternalContainer();
}
/**
*
*
* @generated
*/
public NotificationChain basicSetUnit(UnitInstance newUnit, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newUnit, HintcoPackage.PORT_INSTANCE__UNIT, msgs);
return msgs;
}
/**
*
*
* @generated
*/
public void setUnit(UnitInstance newUnit) {
if (newUnit != eInternalContainer() || (eContainerFeatureID() != HintcoPackage.PORT_INSTANCE__UNIT && newUnit != null)) {
if (EcoreUtil.isAncestor(this, newUnit))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newUnit != null)
msgs = ((InternalEObject)newUnit).eInverseAdd(this, HintcoPackage.UNIT_INSTANCE__PORTS, UnitInstance.class, msgs);
msgs = basicSetUnit(newUnit, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__UNIT, newUnit, newUnit));
}
/**
*
*
* @generated
*/
public PortAdaptation getAdaptation() {
return adaptation;
}
/**
*
*
* @generated
*/
public NotificationChain basicSetAdaptation(PortAdaptation newAdaptation, NotificationChain msgs) {
PortAdaptation oldAdaptation = adaptation;
adaptation = newAdaptation;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__ADAPTATION, oldAdaptation, newAdaptation);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
*
*
* @generated
*/
public void setAdaptation(PortAdaptation newAdaptation) {
if (newAdaptation != adaptation) {
NotificationChain msgs = null;
if (adaptation != null)
msgs = ((InternalEObject)adaptation).eInverseRemove(this, HintcoPackage.PORT_ADAPTATION__PORT, PortAdaptation.class, msgs);
if (newAdaptation != null)
msgs = ((InternalEObject)newAdaptation).eInverseAdd(this, HintcoPackage.PORT_ADAPTATION__PORT, PortAdaptation.class, msgs);
msgs = basicSetAdaptation(newAdaptation, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__ADAPTATION, newAdaptation, newAdaptation));
}
/**
*
*
* @generated
*/
public EList selectedAdaptations() {
PortAdaptation _adaptation = this.getAdaptation();
boolean _tripleEquals = (_adaptation == null);
if (_tripleEquals) {
return new BasicEList(java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList()));
}
boolean _isSelected = this.getAdaptation().isSelected();
if (_isSelected) {
PortAdaptation _adaptation_1 = this.getAdaptation();
if ((_adaptation_1 instanceof DecompositionPortAdaptation)) {
PortAdaptation _adaptation_2 = this.getAdaptation();
return ((DecompositionPortAdaptation) _adaptation_2).selectedAdaptations();
}
PortAdaptation _adaptation_3 = this.getAdaptation();
return new BasicEList(java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList(_adaptation_3)));
}
return new BasicEList(java.util.Collections.unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.newArrayList()));
}
/**
*
*
* @generated
*/
public boolean isInput() {
return false;
}
/**
*
*
* @generated
*/
public boolean getsValueFrom(final PortInstance p) {
return false;
}
/**
*
*
* @generated
*/
public String toString() {
String _string = this.getUnit().toString();
String _plus = (_string + ".");
String _identifier = this.getIdentifier();
return (_plus + _identifier);
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case HintcoPackage.PORT_INSTANCE__UNIT:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetUnit((UnitInstance)otherEnd, msgs);
case HintcoPackage.PORT_INSTANCE__ADAPTATION:
if (adaptation != null)
msgs = ((InternalEObject)adaptation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - HintcoPackage.PORT_INSTANCE__ADAPTATION, null, msgs);
return basicSetAdaptation((PortAdaptation)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case HintcoPackage.PORT_INSTANCE__UNIT:
return basicSetUnit(null, msgs);
case HintcoPackage.PORT_INSTANCE__ADAPTATION:
return basicSetAdaptation(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
*
*
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case HintcoPackage.PORT_INSTANCE__UNIT:
return eInternalContainer().eInverseRemove(this, HintcoPackage.UNIT_INSTANCE__PORTS, UnitInstance.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
*
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
return getIdentifier();
case HintcoPackage.PORT_INSTANCE__UNIT:
if (resolve) return getUnit();
return basicGetUnit();
case HintcoPackage.PORT_INSTANCE__ADAPTATION:
return getAdaptation();
}
return super.eGet(featureID, resolve, coreType);
}
/**
*
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
setIdentifier((String)newValue);
return;
case HintcoPackage.PORT_INSTANCE__UNIT:
setUnit((UnitInstance)newValue);
return;
case HintcoPackage.PORT_INSTANCE__ADAPTATION:
setAdaptation((PortAdaptation)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
*
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
setIdentifier(IDENTIFIER_EDEFAULT);
return;
case HintcoPackage.PORT_INSTANCE__UNIT:
setUnit((UnitInstance)null);
return;
case HintcoPackage.PORT_INSTANCE__ADAPTATION:
setAdaptation((PortAdaptation)null);
return;
}
super.eUnset(featureID);
}
/**
*
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
return IDENTIFIER_EDEFAULT == null ? identifier != null : !IDENTIFIER_EDEFAULT.equals(identifier);
case HintcoPackage.PORT_INSTANCE__UNIT:
return basicGetUnit() != null;
case HintcoPackage.PORT_INSTANCE__ADAPTATION:
return adaptation != null;
}
return super.eIsSet(featureID);
}
/**
*
*
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class> baseClass) {
if (baseClass == IDed.class) {
switch (derivedFeatureID) {
case HintcoPackage.PORT_INSTANCE__IDENTIFIER: return HintcoPackage.IDED__IDENTIFIER;
default: return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
*
*
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID, Class> baseClass) {
if (baseClass == IDed.class) {
switch (baseFeatureID) {
case HintcoPackage.IDED__IDENTIFIER: return HintcoPackage.PORT_INSTANCE__IDENTIFIER;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
*
*
* @generated
*/
@Override
public Object eInvoke(int operationID, EList> arguments) throws InvocationTargetException {
switch (operationID) {
case HintcoPackage.PORT_INSTANCE___SELECTED_ADAPTATIONS:
return selectedAdaptations();
case HintcoPackage.PORT_INSTANCE___IS_INPUT:
return isInput();
case HintcoPackage.PORT_INSTANCE___GETS_VALUE_FROM__PORTINSTANCE:
return getsValueFrom((PortInstance)arguments.get(0));
case HintcoPackage.PORT_INSTANCE___TO_STRING:
return toString();
}
return super.eInvoke(operationID, arguments);
}
} //PortInstanceImpl