/**
* Copyright (c) 2007 IBM Corporation and others.
* 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
*
* Contributors:
* IBM - Initial API and implementation
*/
package org.eclipse.emf.test.models.ref.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.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.test.models.ref.A;
import org.eclipse.emf.test.models.ref.B;
import org.eclipse.emf.test.models.ref.C;
import org.eclipse.emf.test.models.ref.C2;
import org.eclipse.emf.test.models.ref.RefPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>A</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.emf.test.models.ref.impl.AImpl#getB <em>B</em>}</li>
* <li>{@link org.eclipse.emf.test.models.ref.impl.AImpl#getC2 <em>C2</em>}</li>
* <li>{@link org.eclipse.emf.test.models.ref.impl.AImpl#getC <em>C</em>}</li>
* </ul>
*
* @generated
*/
public class AImpl extends EObjectImpl implements A
{
/**
* The cached value of the '{@link #getB() <em>B</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getB()
* @generated
* @ordered
*/
protected B b;
/**
* The cached value of the '{@link #getC() <em>C</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getC()
* @generated
* @ordered
*/
protected C c;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return RefPackage.Literals.A;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public B getB()
{
if (b != null && b.eIsProxy())
{
InternalEObject oldB = (InternalEObject)b;
b = (B)eResolveProxy(oldB);
if (b != oldB)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, RefPackage.A__B, oldB, b));
}
}
return b;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public B basicGetB()
{
return b;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetB(B newB, NotificationChain msgs)
{
B oldB = b;
b = newB;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RefPackage.A__B, oldB, newB);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setB(B newB)
{
if (newB != b)
{
NotificationChain msgs = null;
if (b != null)
msgs = ((InternalEObject)b).eInverseRemove(this, RefPackage.B__A, B.class, msgs);
if (newB != null)
msgs = ((InternalEObject)newB).eInverseAdd(this, RefPackage.B__A, B.class, msgs);
msgs = basicSetB(newB, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RefPackage.A__B, newB, newB));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public C2 getC2()
{
if (eContainerFeatureID() != RefPackage.A__C2) return null;
return (C2)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetC2(C2 newC2, NotificationChain msgs)
{
msgs = eBasicSetContainer((InternalEObject)newC2, RefPackage.A__C2, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setC2(C2 newC2)
{
if (newC2 != eInternalContainer() || (eContainerFeatureID() != RefPackage.A__C2 && newC2 != null))
{
if (EcoreUtil.isAncestor(this, newC2))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newC2 != null)
msgs = ((InternalEObject)newC2).eInverseAdd(this, RefPackage.C2__A, C2.class, msgs);
msgs = basicSetC2(newC2, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RefPackage.A__C2, newC2, newC2));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public C getC()
{
if (c != null && c.eIsProxy())
{
InternalEObject oldC = (InternalEObject)c;
c = (C)eResolveProxy(oldC);
if (c != oldC)
{
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, RefPackage.A__C, oldC, c));
}
}
return c;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public C basicGetC()
{
return c;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setC(C newC)
{
C oldC = c;
c = newC;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RefPackage.A__C, oldC, c));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case RefPackage.A__B:
if (b != null)
msgs = ((InternalEObject)b).eInverseRemove(this, RefPackage.B__A, B.class, msgs);
return basicSetB((B)otherEnd, msgs);
case RefPackage.A__C2:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetC2((C2)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case RefPackage.A__B:
return basicSetB(null, msgs);
case RefPackage.A__C2:
return basicSetC2(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
{
switch (eContainerFeatureID())
{
case RefPackage.A__C2:
return eInternalContainer().eInverseRemove(this, RefPackage.C2__A, C2.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case RefPackage.A__B:
if (resolve) return getB();
return basicGetB();
case RefPackage.A__C2:
return getC2();
case RefPackage.A__C:
if (resolve) return getC();
return basicGetC();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case RefPackage.A__B:
setB((B)newValue);
return;
case RefPackage.A__C2:
setC2((C2)newValue);
return;
case RefPackage.A__C:
setC((C)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case RefPackage.A__B:
setB((B)null);
return;
case RefPackage.A__C2:
setC2((C2)null);
return;
case RefPackage.A__C:
setC((C)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case RefPackage.A__B:
return b != null;
case RefPackage.A__C2:
return getC2() != null;
case RefPackage.A__C:
return c != null;
}
return super.eIsSet(featureID);
}
} //AImpl