/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.eclipse.papyrus.views.properties.contexts.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.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.papyrus.views.properties.contexts.ContextsPackage;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.contexts.DataContextPackage;
import org.eclipse.papyrus.views.properties.contexts.Property;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Data Context Element</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.papyrus.views.properties.contexts.impl.DataContextElementImpl#getName <em>Name</em>}</li>
* <li>{@link org.eclipse.papyrus.views.properties.contexts.impl.DataContextElementImpl#getProperties <em>Properties</em>}</li>
* <li>{@link org.eclipse.papyrus.views.properties.contexts.impl.DataContextElementImpl#getPackage <em>Package</em>}</li>
* <li>{@link org.eclipse.papyrus.views.properties.contexts.impl.DataContextElementImpl#getSupertypes <em>Supertypes</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class DataContextElementImpl extends EObjectImpl implements DataContextElement {
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getProperties()
* @generated
* @ordered
*/
protected EList<Property> properties;
/**
* The cached value of the '{@link #getSupertypes() <em>Supertypes</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSupertypes()
* @generated
* @ordered
*/
protected EList<DataContextElement> supertypes;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected DataContextElementImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ContextsPackage.Literals.DATA_CONTEXT_ELEMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName() {
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName) {
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ContextsPackage.DATA_CONTEXT_ELEMENT__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Property> getProperties() {
if (properties == null) {
properties = new EObjectContainmentWithInverseEList<Property>(Property.class, this, ContextsPackage.DATA_CONTEXT_ELEMENT__PROPERTIES, ContextsPackage.PROPERTY__CONTEXT_ELEMENT);
}
return properties;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public DataContextPackage getPackage() {
if (eContainerFeatureID() != ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE) return null;
return (DataContextPackage)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetPackage(DataContextPackage newPackage, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newPackage, ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPackage(DataContextPackage newPackage) {
if (newPackage != eInternalContainer() || (eContainerFeatureID() != ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE && newPackage != null)) {
if (EcoreUtil.isAncestor(this, newPackage))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newPackage != null)
msgs = ((InternalEObject)newPackage).eInverseAdd(this, ContextsPackage.DATA_CONTEXT_PACKAGE__ELEMENTS, DataContextPackage.class, msgs);
msgs = basicSetPackage(newPackage, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE, newPackage, newPackage));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<DataContextElement> getSupertypes() {
if (supertypes == null) {
supertypes = new EObjectResolvingEList<DataContextElement>(DataContextElement.class, this, ContextsPackage.DATA_CONTEXT_ELEMENT__SUPERTYPES);
}
return supertypes;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ContextsPackage.DATA_CONTEXT_ELEMENT__PROPERTIES:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getProperties()).basicAdd(otherEnd, msgs);
case ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetPackage((DataContextPackage)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 ContextsPackage.DATA_CONTEXT_ELEMENT__PROPERTIES:
return ((InternalEList<?>)getProperties()).basicRemove(otherEnd, msgs);
case ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE:
return basicSetPackage(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE:
return eInternalContainer().eInverseRemove(this, ContextsPackage.DATA_CONTEXT_PACKAGE__ELEMENTS, DataContextPackage.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 ContextsPackage.DATA_CONTEXT_ELEMENT__NAME:
return getName();
case ContextsPackage.DATA_CONTEXT_ELEMENT__PROPERTIES:
return getProperties();
case ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE:
return getPackage();
case ContextsPackage.DATA_CONTEXT_ELEMENT__SUPERTYPES:
return getSupertypes();
}
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 ContextsPackage.DATA_CONTEXT_ELEMENT__NAME:
setName((String)newValue);
return;
case ContextsPackage.DATA_CONTEXT_ELEMENT__PROPERTIES:
getProperties().clear();
getProperties().addAll((Collection<? extends Property>)newValue);
return;
case ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE:
setPackage((DataContextPackage)newValue);
return;
case ContextsPackage.DATA_CONTEXT_ELEMENT__SUPERTYPES:
getSupertypes().clear();
getSupertypes().addAll((Collection<? extends DataContextElement>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ContextsPackage.DATA_CONTEXT_ELEMENT__NAME:
setName(NAME_EDEFAULT);
return;
case ContextsPackage.DATA_CONTEXT_ELEMENT__PROPERTIES:
getProperties().clear();
return;
case ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE:
setPackage((DataContextPackage)null);
return;
case ContextsPackage.DATA_CONTEXT_ELEMENT__SUPERTYPES:
getSupertypes().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ContextsPackage.DATA_CONTEXT_ELEMENT__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case ContextsPackage.DATA_CONTEXT_ELEMENT__PROPERTIES:
return properties != null && !properties.isEmpty();
case ContextsPackage.DATA_CONTEXT_ELEMENT__PACKAGE:
return getPackage() != null;
case ContextsPackage.DATA_CONTEXT_ELEMENT__SUPERTYPES:
return supertypes != null && !supertypes.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //DataContextElementImpl