/******************************************************************************* * Copyright (c) 2012 BMW Car IT and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ package org.jnario.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.EObjectContainmentEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; import org.jnario.ExampleCell; import org.eclipse.xtext.xbase.XExpression; import org.jnario.ExampleRow; import org.jnario.ExampleTable; import org.jnario.JnarioPackage; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Example Row</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.jnario.impl.ExampleRowImpl#getCells <em>Cells</em>}</li> * <li>{@link org.jnario.impl.ExampleRowImpl#getTable <em>Table</em>}</li> * </ul> * </p> * * @generated */ public class ExampleRowImpl extends EObjectImpl implements ExampleRow { /** * The cached value of the '{@link #getCells() <em>Cells</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCells() * @generated * @ordered */ protected EList<ExampleCell> cells; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected ExampleRowImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return JnarioPackage.Literals.EXAMPLE_ROW; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public EList<ExampleCell> getCells() { if (cells == null) { cells = new EObjectContainmentEList<ExampleCell>(ExampleCell.class, this, JnarioPackage.EXAMPLE_ROW__CELLS); } return cells; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public ExampleTable getTable() { if (eContainerFeatureID() != JnarioPackage.EXAMPLE_ROW__TABLE) return null; return (ExampleTable)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTable(ExampleTable newTable, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newTable, JnarioPackage.EXAMPLE_ROW__TABLE, msgs); return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setTable(ExampleTable newTable) { if (newTable != eInternalContainer() || (eContainerFeatureID() != JnarioPackage.EXAMPLE_ROW__TABLE && newTable != null)) { if (EcoreUtil.isAncestor(this, newTable)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newTable != null) msgs = ((InternalEObject)newTable).eInverseAdd(this, JnarioPackage.EXAMPLE_TABLE__ROWS, ExampleTable.class, msgs); msgs = basicSetTable(newTable, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, JnarioPackage.EXAMPLE_ROW__TABLE, newTable, newTable)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case JnarioPackage.EXAMPLE_ROW__TABLE: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetTable((ExampleTable)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 JnarioPackage.EXAMPLE_ROW__CELLS: return ((InternalEList<?>)getCells()).basicRemove(otherEnd, msgs); case JnarioPackage.EXAMPLE_ROW__TABLE: return basicSetTable(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case JnarioPackage.EXAMPLE_ROW__TABLE: return eInternalContainer().eInverseRemove(this, JnarioPackage.EXAMPLE_TABLE__ROWS, ExampleTable.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 JnarioPackage.EXAMPLE_ROW__CELLS: return getCells(); case JnarioPackage.EXAMPLE_ROW__TABLE: return getTable(); } 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 JnarioPackage.EXAMPLE_ROW__CELLS: getCells().clear(); getCells().addAll((Collection<? extends ExampleCell>)newValue); return; case JnarioPackage.EXAMPLE_ROW__TABLE: setTable((ExampleTable)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case JnarioPackage.EXAMPLE_ROW__CELLS: getCells().clear(); return; case JnarioPackage.EXAMPLE_ROW__TABLE: setTable((ExampleTable)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case JnarioPackage.EXAMPLE_ROW__CELLS: return cells != null && !cells.isEmpty(); case JnarioPackage.EXAMPLE_ROW__TABLE: return getTable() != null; } return super.eIsSet(featureID); } } //ExampleRowImpl