blob: 4b1bb68ee22454e4a8755420dbeced13db06ee03 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2010 BMW Car IT, Technische Universitaet Muenchen, 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
*
* Contributors:
* BMW Car IT - Initial API and implementation
* Technische Universitaet Muenchen - Major refactoring and extension
*******************************************************************************/
package org.eclipse.emf.edapt.spi.migration.impl;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
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.EcoreUtil;
import org.eclipse.emf.edapt.spi.migration.AttributeSlot;
import org.eclipse.emf.edapt.spi.migration.Instance;
import org.eclipse.emf.edapt.spi.migration.MigrationPackage;
import org.eclipse.emf.edapt.spi.migration.ReferenceSlot;
import org.eclipse.emf.edapt.spi.migration.Slot;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Slot</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.edapt.spi.migration.impl.SlotImpl#getInstance <em>Instance</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class SlotImpl extends EObjectImpl implements Slot {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected SlotImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return MigrationPackage.Literals.SLOT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public Instance getInstance() {
if (eContainerFeatureID() != MigrationPackage.SLOT__INSTANCE) {
return null;
}
return (Instance) eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetInstance(Instance newInstance, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newInstance, MigrationPackage.SLOT__INSTANCE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setInstance(Instance newInstance) {
if (newInstance != eInternalContainer()
|| eContainerFeatureID() != MigrationPackage.SLOT__INSTANCE && newInstance != null) {
if (EcoreUtil.isAncestor(this, (EObject) newInstance)) {
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
}
NotificationChain msgs = null;
if (eInternalContainer() != null) {
msgs = eBasicRemoveFromContainer(msgs);
}
if (newInstance != null) {
msgs = ((InternalEObject) newInstance).eInverseAdd(this, MigrationPackage.INSTANCE__SLOTS,
Instance.class, msgs);
}
msgs = basicSetInstance(newInstance, msgs);
if (msgs != null) {
msgs.dispatch();
}
}
else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, MigrationPackage.SLOT__INSTANCE, newInstance,
newInstance));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public EStructuralFeature getEFeature() {
if (this instanceof AttributeSlot) {
return ((AttributeSlot) this).getEAttribute();
}
else if (this instanceof ReferenceSlot) {
return ((ReferenceSlot) this).getEReference();
}
return null;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MigrationPackage.SLOT__INSTANCE:
if (eInternalContainer() != null) {
msgs = eBasicRemoveFromContainer(msgs);
}
return basicSetInstance((Instance) 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 MigrationPackage.SLOT__INSTANCE:
return basicSetInstance(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case MigrationPackage.SLOT__INSTANCE:
return eInternalContainer().eInverseRemove(this, MigrationPackage.INSTANCE__SLOTS, Instance.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 MigrationPackage.SLOT__INSTANCE:
return getInstance();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case MigrationPackage.SLOT__INSTANCE:
setInstance((Instance) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MigrationPackage.SLOT__INSTANCE:
setInstance((Instance) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MigrationPackage.SLOT__INSTANCE:
return getInstance() != null;
}
return super.eIsSet(featureID);
}
/**
* Get the values of a slot
*
* @return Values
*/
public abstract List<?> getValues();
} // SlotImpl