/**
* 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 java.util.Collection;
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.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.test.models.ref.C;
import org.eclipse.emf.test.models.ref.C4;
import org.eclipse.emf.test.models.ref.D;
import org.eclipse.emf.test.models.ref.RefPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>C4</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.emf.test.models.ref.impl.C4Impl#getC <em>C</em>}</li>
* <li>{@link org.eclipse.emf.test.models.ref.impl.C4Impl#getD <em>D</em>}</li>
* </ul>
*
* @generated
*/
public class C4Impl extends EObjectImpl implements C4
{
/**
* The cached value of the '{@link #getC() <em>C</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getC()
* @generated
* @ordered
*/
protected C c;
/**
* The cached value of the '{@link #getD() <em>D</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getD()
* @generated
* @ordered
*/
protected EList<D> d;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected C4Impl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return RefPackage.Literals.C4;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public C getC()
{
return c;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetC(C newC, NotificationChain msgs)
{
C oldC = c;
c = newC;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, RefPackage.C4__C, oldC, newC);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setC(C newC)
{
if (newC != c)
{
NotificationChain msgs = null;
if (c != null)
msgs = ((InternalEObject)c).eInverseRemove(this, RefPackage.C__C4, C.class, msgs);
if (newC != null)
msgs = ((InternalEObject)newC).eInverseAdd(this, RefPackage.C__C4, C.class, msgs);
msgs = basicSetC(newC, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RefPackage.C4__C, newC, newC));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<D> getD()
{
if (d == null)
{
d = new EObjectContainmentWithInverseEList<D>(D.class, this, RefPackage.C4__D, RefPackage.D__C4);
}
return d;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case RefPackage.C4__C:
if (c != null)
msgs = ((InternalEObject)c).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - RefPackage.C4__C, null, msgs);
return basicSetC((C)otherEnd, msgs);
case RefPackage.C4__D:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getD()).basicAdd(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.C4__C:
return basicSetC(null, msgs);
case RefPackage.C4__D:
return ((InternalEList<?>)getD()).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 RefPackage.C4__C:
return getC();
case RefPackage.C4__D:
return getD();
}
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 RefPackage.C4__C:
setC((C)newValue);
return;
case RefPackage.C4__D:
getD().clear();
getD().addAll((Collection<? extends D>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case RefPackage.C4__C:
setC((C)null);
return;
case RefPackage.C4__D:
getD().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case RefPackage.C4__C:
return c != null;
case RefPackage.C4__D:
return d != null && !d.isEmpty();
}
return super.eIsSet(featureID);
}
} //C4Impl