/**
*/
package com.rcpcompany.uibindings.tests.shop.internal;
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.util.EObjectEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import com.rcpcompany.uibindings.moao.internal.NamedObjectImpl;
import com.rcpcompany.uibindings.tests.shop.Customer;
import com.rcpcompany.uibindings.tests.shop.CustomerGroup;
import com.rcpcompany.uibindings.tests.shop.Shop;
import com.rcpcompany.uibindings.tests.shop.ShopPackage;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Customer Group</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link com.rcpcompany.uibindings.tests.shop.internal.CustomerGroupImpl#getShop <em>Shop</em>}
* </li>
* <li>{@link com.rcpcompany.uibindings.tests.shop.internal.CustomerGroupImpl#getCustomers <em>
* Customers</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class CustomerGroupImpl extends NamedObjectImpl implements CustomerGroup {
/**
* The cached value of the '{@link #getCustomers() <em>Customers</em>}' reference list. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getCustomers()
* @generated
* @ordered
*/
protected EList<Customer> customers;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected CustomerGroupImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ShopPackage.Literals.CUSTOMER_GROUP;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Shop getShop() {
if (eContainerFeatureID() != ShopPackage.CUSTOMER_GROUP__SHOP) return null;
return (Shop) eInternalContainer();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetShop(Shop newShop, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newShop, ShopPackage.CUSTOMER_GROUP__SHOP, msgs);
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setShop(Shop newShop) {
if (newShop != eInternalContainer()
|| (eContainerFeatureID() != ShopPackage.CUSTOMER_GROUP__SHOP && newShop != null)) {
if (EcoreUtil.isAncestor(this, newShop))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs);
if (newShop != null)
msgs = ((InternalEObject) newShop).eInverseAdd(this, ShopPackage.SHOP__CUSTOMER_GROUPS, Shop.class,
msgs);
msgs = basicSetShop(newShop, msgs);
if (msgs != null) msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ShopPackage.CUSTOMER_GROUP__SHOP, newShop, newShop));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public EList<Customer> getCustomers() {
if (customers == null) {
customers = new EObjectEList<Customer>(Customer.class, this, ShopPackage.CUSTOMER_GROUP__CUSTOMERS);
}
return customers;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ShopPackage.CUSTOMER_GROUP__SHOP:
if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs);
return basicSetShop((Shop) 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 ShopPackage.CUSTOMER_GROUP__SHOP:
return basicSetShop(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case ShopPackage.CUSTOMER_GROUP__SHOP:
return eInternalContainer().eInverseRemove(this, ShopPackage.SHOP__CUSTOMER_GROUPS, Shop.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 ShopPackage.CUSTOMER_GROUP__SHOP:
return getShop();
case ShopPackage.CUSTOMER_GROUP__CUSTOMERS:
return getCustomers();
}
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 ShopPackage.CUSTOMER_GROUP__SHOP:
setShop((Shop) newValue);
return;
case ShopPackage.CUSTOMER_GROUP__CUSTOMERS:
getCustomers().clear();
getCustomers().addAll((Collection<? extends Customer>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ShopPackage.CUSTOMER_GROUP__SHOP:
setShop((Shop) null);
return;
case ShopPackage.CUSTOMER_GROUP__CUSTOMERS:
getCustomers().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ShopPackage.CUSTOMER_GROUP__SHOP:
return getShop() != null;
case ShopPackage.CUSTOMER_GROUP__CUSTOMERS:
return customers != null && !customers.isEmpty();
}
return super.eIsSet(featureID);
}
} // CustomerGroupImpl