/** * <copyright> * </copyright> * * $Id$ */ package org.eclipse.acceleo.tutorial.webapp.impl; import java.util.Collection; import org.eclipse.acceleo.tutorial.webapp.Application; import org.eclipse.acceleo.tutorial.webapp.Router; import org.eclipse.acceleo.tutorial.webapp.RouterMapping; 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.EObjectContainmentEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Router</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.acceleo.tutorial.webapp.impl.RouterImpl#getMappings <em>Mappings</em>}</li> * <li>{@link org.eclipse.acceleo.tutorial.webapp.impl.RouterImpl#getApplication <em>Application</em>}</li> * </ul> * </p> * * @generated */ public class RouterImpl extends NamedElementImpl implements Router { /** * The cached value of the '{@link #getMappings() <em>Mappings</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getMappings() * @generated * @ordered */ protected EList<RouterMapping> mappings; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected RouterImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return WebappPackage.Literals.ROUTER; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<RouterMapping> getMappings() { if (mappings == null) { mappings = new EObjectContainmentEList<RouterMapping>(RouterMapping.class, this, WebappPackage.ROUTER__MAPPINGS); } return mappings; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Application getApplication() { if (eContainerFeatureID() != WebappPackage.ROUTER__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.ROUTER__APPLICATION, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setApplication(Application newApplication) { if (newApplication != eInternalContainer() || (eContainerFeatureID() != WebappPackage.ROUTER__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__ROUTER, Application.class, msgs); msgs = basicSetApplication(newApplication, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, WebappPackage.ROUTER__APPLICATION, newApplication, newApplication)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case WebappPackage.ROUTER__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.ROUTER__MAPPINGS: return ((InternalEList<?>)getMappings()).basicRemove(otherEnd, msgs); case WebappPackage.ROUTER__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.ROUTER__APPLICATION: return eInternalContainer().eInverseRemove(this, WebappPackage.APPLICATION__ROUTER, 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.ROUTER__MAPPINGS: return getMappings(); case WebappPackage.ROUTER__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 WebappPackage.ROUTER__MAPPINGS: getMappings().clear(); getMappings().addAll((Collection<? extends RouterMapping>)newValue); return; case WebappPackage.ROUTER__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 WebappPackage.ROUTER__MAPPINGS: getMappings().clear(); return; case WebappPackage.ROUTER__APPLICATION: setApplication((Application)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case WebappPackage.ROUTER__MAPPINGS: return mappings != null && !mappings.isEmpty(); case WebappPackage.ROUTER__APPLICATION: return getApplication() != null; } return super.eIsSet(featureID); } } //RouterImpl