/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.reuseware.air.language.cmsl.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.reuseware.air.language.cmsl.BaseReference;
import org.reuseware.air.language.cmsl.Cardinality;
import org.reuseware.air.language.cmsl.CmslPackage;
import org.reuseware.air.language.cmsl.Reference;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Reference</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.reuseware.air.language.cmsl.impl.ReferenceImpl#getBase <em>Base</em>}</li>
* <li>{@link org.reuseware.air.language.cmsl.impl.ReferenceImpl#getCardinality <em>Cardinality</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ReferenceImpl extends EObjectImpl implements Reference {
/**
* The cached value of the '{@link #getBase() <em>Base</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBase()
* @generated
* @ordered
*/
protected BaseReference base;
/**
* The cached value of the '{@link #getCardinality() <em>Cardinality</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCardinality()
* @generated
* @ordered
*/
protected Cardinality cardinality;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ReferenceImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return CmslPackage.Literals.REFERENCE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public BaseReference getBase() {
return base;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBase(BaseReference newBase, NotificationChain msgs) {
BaseReference oldBase = base;
base = newBase;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CmslPackage.REFERENCE__BASE, oldBase, newBase);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBase(BaseReference newBase) {
if (newBase != base)
{
NotificationChain msgs = null;
if (base != null)
msgs = ((InternalEObject)base).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CmslPackage.REFERENCE__BASE, null, msgs);
if (newBase != null)
msgs = ((InternalEObject)newBase).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CmslPackage.REFERENCE__BASE, null, msgs);
msgs = basicSetBase(newBase, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CmslPackage.REFERENCE__BASE, newBase, newBase));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Cardinality getCardinality() {
return cardinality;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCardinality(Cardinality newCardinality, NotificationChain msgs) {
Cardinality oldCardinality = cardinality;
cardinality = newCardinality;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CmslPackage.REFERENCE__CARDINALITY, oldCardinality, newCardinality);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setCardinality(Cardinality newCardinality) {
if (newCardinality != cardinality)
{
NotificationChain msgs = null;
if (cardinality != null)
msgs = ((InternalEObject)cardinality).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CmslPackage.REFERENCE__CARDINALITY, null, msgs);
if (newCardinality != null)
msgs = ((InternalEObject)newCardinality).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CmslPackage.REFERENCE__CARDINALITY, null, msgs);
msgs = basicSetCardinality(newCardinality, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CmslPackage.REFERENCE__CARDINALITY, newCardinality, newCardinality));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID)
{
case CmslPackage.REFERENCE__BASE:
return basicSetBase(null, msgs);
case CmslPackage.REFERENCE__CARDINALITY:
return basicSetCardinality(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID)
{
case CmslPackage.REFERENCE__BASE:
return getBase();
case CmslPackage.REFERENCE__CARDINALITY:
return getCardinality();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID)
{
case CmslPackage.REFERENCE__BASE:
setBase((BaseReference)newValue);
return;
case CmslPackage.REFERENCE__CARDINALITY:
setCardinality((Cardinality)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID)
{
case CmslPackage.REFERENCE__BASE:
setBase((BaseReference)null);
return;
case CmslPackage.REFERENCE__CARDINALITY:
setCardinality((Cardinality)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID)
{
case CmslPackage.REFERENCE__BASE:
return base != null;
case CmslPackage.REFERENCE__CARDINALITY:
return cardinality != null;
}
return super.eIsSet(featureID);
}
} //ReferenceImpl