/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.eclipse.acceleo.tutorial.webapp.impl;
import java.util.Collection;
import org.eclipse.acceleo.tutorial.webapp.AbstractView;
import org.eclipse.acceleo.tutorial.webapp.Application;
import org.eclipse.acceleo.tutorial.webapp.Operation;
import org.eclipse.acceleo.tutorial.webapp.WebappPackage;
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.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Abstract View</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.acceleo.tutorial.webapp.impl.AbstractViewImpl#getOperations <em>Operations</em>}</li>
* <li>{@link org.eclipse.acceleo.tutorial.webapp.impl.AbstractViewImpl#getApplication <em>Application</em>}</li>
* <li>{@link org.eclipse.acceleo.tutorial.webapp.impl.AbstractViewImpl#getDescription <em>Description</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class AbstractViewImpl extends NamedElementImpl implements AbstractView {
/**
* The cached value of the '{@link #getOperations() <em>Operations</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOperations()
* @generated
* @ordered
*/
protected EList<Operation> operations;
/**
* The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDescription()
* @generated
* @ordered
*/
protected static final String DESCRIPTION_EDEFAULT = null;
/**
* The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDescription()
* @generated
* @ordered
*/
protected String description = DESCRIPTION_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AbstractViewImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return WebappPackage.Literals.ABSTRACT_VIEW;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Operation> getOperations() {
if (operations == null) {
operations = new EObjectResolvingEList<Operation>(Operation.class, this, WebappPackage.ABSTRACT_VIEW__OPERATIONS);
}
return operations;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Application getApplication() {
if (eContainerFeatureID() != WebappPackage.ABSTRACT_VIEW__APPLICATION) return null;
return (Application)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetApplication(Application newApplication, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newApplication, WebappPackage.ABSTRACT_VIEW__APPLICATION, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setApplication(Application newApplication) {
if (newApplication != eInternalContainer() || (eContainerFeatureID() != WebappPackage.ABSTRACT_VIEW__APPLICATION && newApplication != null)) {
if (EcoreUtil.isAncestor(this, newApplication))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newApplication != null)
msgs = ((InternalEObject)newApplication).eInverseAdd(this, WebappPackage.APPLICATION__VIEWS, Application.class, msgs);
msgs = basicSetApplication(newApplication, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WebappPackage.ABSTRACT_VIEW__APPLICATION, newApplication, newApplication));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getDescription() {
return description;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDescription(String newDescription) {
String oldDescription = description;
description = newDescription;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WebappPackage.ABSTRACT_VIEW__DESCRIPTION, oldDescription, description));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case WebappPackage.ABSTRACT_VIEW__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 WebappPackage.ABSTRACT_VIEW__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 WebappPackage.ABSTRACT_VIEW__APPLICATION:
return eInternalContainer().eInverseRemove(this, WebappPackage.APPLICATION__VIEWS, 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 WebappPackage.ABSTRACT_VIEW__OPERATIONS:
return getOperations();
case WebappPackage.ABSTRACT_VIEW__APPLICATION:
return getApplication();
case WebappPackage.ABSTRACT_VIEW__DESCRIPTION:
return getDescription();
}
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 WebappPackage.ABSTRACT_VIEW__OPERATIONS:
getOperations().clear();
getOperations().addAll((Collection<? extends Operation>)newValue);
return;
case WebappPackage.ABSTRACT_VIEW__APPLICATION:
setApplication((Application)newValue);
return;
case WebappPackage.ABSTRACT_VIEW__DESCRIPTION:
setDescription((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case WebappPackage.ABSTRACT_VIEW__OPERATIONS:
getOperations().clear();
return;
case WebappPackage.ABSTRACT_VIEW__APPLICATION:
setApplication((Application)null);
return;
case WebappPackage.ABSTRACT_VIEW__DESCRIPTION:
setDescription(DESCRIPTION_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case WebappPackage.ABSTRACT_VIEW__OPERATIONS:
return operations != null && !operations.isEmpty();
case WebappPackage.ABSTRACT_VIEW__APPLICATION:
return getApplication() != null;
case WebappPackage.ABSTRACT_VIEW__DESCRIPTION:
return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
}
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(" (description: ");
result.append(description);
result.append(')');
return result.toString();
}
} //AbstractViewImpl