/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.obeonetwork.pim.gen.backbone.model.backbone.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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.obeonetwork.pim.gen.backbone.model.backbone.Application;
import org.obeonetwork.pim.gen.backbone.model.backbone.Attribute;
import org.obeonetwork.pim.gen.backbone.model.backbone.BackbonePackage;
import org.obeonetwork.pim.gen.backbone.model.backbone.Model;
import org.obeonetwork.pim.gen.backbone.model.backbone.Operation;
import org.obeonetwork.pim.gen.backbone.model.backbone.Reference;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Model</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.obeonetwork.pim.gen.backbone.model.backbone.impl.ModelImpl#getAttributes <em>Attributes</em>}</li>
* <li>{@link org.obeonetwork.pim.gen.backbone.model.backbone.impl.ModelImpl#getReferences <em>References</em>}</li>
* <li>{@link org.obeonetwork.pim.gen.backbone.model.backbone.impl.ModelImpl#getOperations <em>Operations</em>}</li>
* <li>{@link org.obeonetwork.pim.gen.backbone.model.backbone.impl.ModelImpl#getApplication <em>Application</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ModelImpl extends NamedElementImpl implements Model {
/**
* The cached value of the '{@link #getAttributes() <em>Attributes</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAttributes()
* @generated
* @ordered
*/
protected EList<Attribute> attributes;
/**
* The cached value of the '{@link #getReferences() <em>References</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReferences()
* @generated
* @ordered
*/
protected EList<Reference> references;
/**
* The cached value of the '{@link #getOperations() <em>Operations</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOperations()
* @generated
* @ordered
*/
protected EList<Operation> operations;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ModelImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return BackbonePackage.Literals.MODEL;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Attribute> getAttributes() {
if (attributes == null) {
attributes = new EObjectContainmentEList<Attribute>(Attribute.class, this, BackbonePackage.MODEL__ATTRIBUTES);
}
return attributes;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Reference> getReferences() {
if (references == null) {
references = new EObjectContainmentEList<Reference>(Reference.class, this, BackbonePackage.MODEL__REFERENCES);
}
return references;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Operation> getOperations() {
if (operations == null) {
operations = new EObjectContainmentEList<Operation>(Operation.class, this, BackbonePackage.MODEL__OPERATIONS);
}
return operations;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Application getApplication() {
if (eContainerFeatureID() != BackbonePackage.MODEL__APPLICATION) return null;
return (Application)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetApplication(Application newApplication, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newApplication, BackbonePackage.MODEL__APPLICATION, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setApplication(Application newApplication) {
if (newApplication != eInternalContainer() || (eContainerFeatureID() != BackbonePackage.MODEL__APPLICATION && newApplication != null)) {
if (EcoreUtil.isAncestor(this, newApplication))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newApplication != null)
msgs = ((InternalEObject)newApplication).eInverseAdd(this, BackbonePackage.APPLICATION__MODELS, Application.class, msgs);
msgs = basicSetApplication(newApplication, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BackbonePackage.MODEL__APPLICATION, newApplication, newApplication));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case BackbonePackage.MODEL__APPLICATION:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetApplication((Application)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 BackbonePackage.MODEL__ATTRIBUTES:
return ((InternalEList<?>)getAttributes()).basicRemove(otherEnd, msgs);
case BackbonePackage.MODEL__REFERENCES:
return ((InternalEList<?>)getReferences()).basicRemove(otherEnd, msgs);
case BackbonePackage.MODEL__OPERATIONS:
return ((InternalEList<?>)getOperations()).basicRemove(otherEnd, msgs);
case BackbonePackage.MODEL__APPLICATION:
return basicSetApplication(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case BackbonePackage.MODEL__APPLICATION:
return eInternalContainer().eInverseRemove(this, BackbonePackage.APPLICATION__MODELS, Application.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 BackbonePackage.MODEL__ATTRIBUTES:
return getAttributes();
case BackbonePackage.MODEL__REFERENCES:
return getReferences();
case BackbonePackage.MODEL__OPERATIONS:
return getOperations();
case BackbonePackage.MODEL__APPLICATION:
return getApplication();
}
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 BackbonePackage.MODEL__ATTRIBUTES:
getAttributes().clear();
getAttributes().addAll((Collection<? extends Attribute>)newValue);
return;
case BackbonePackage.MODEL__REFERENCES:
getReferences().clear();
getReferences().addAll((Collection<? extends Reference>)newValue);
return;
case BackbonePackage.MODEL__OPERATIONS:
getOperations().clear();
getOperations().addAll((Collection<? extends Operation>)newValue);
return;
case BackbonePackage.MODEL__APPLICATION:
setApplication((Application)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BackbonePackage.MODEL__ATTRIBUTES:
getAttributes().clear();
return;
case BackbonePackage.MODEL__REFERENCES:
getReferences().clear();
return;
case BackbonePackage.MODEL__OPERATIONS:
getOperations().clear();
return;
case BackbonePackage.MODEL__APPLICATION:
setApplication((Application)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BackbonePackage.MODEL__ATTRIBUTES:
return attributes != null && !attributes.isEmpty();
case BackbonePackage.MODEL__REFERENCES:
return references != null && !references.isEmpty();
case BackbonePackage.MODEL__OPERATIONS:
return operations != null && !operations.isEmpty();
case BackbonePackage.MODEL__APPLICATION:
return getApplication() != null;
}
return super.eIsSet(featureID);
}
} //ModelImpl