| /******************************************************************************* |
| * 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.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.EObject; |
| 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.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.emf.edapt.spi.migration.Instance; |
| import org.eclipse.emf.edapt.spi.migration.MigrationFactory; |
| import org.eclipse.emf.edapt.spi.migration.MigrationPackage; |
| import org.eclipse.emf.edapt.spi.migration.Model; |
| import org.eclipse.emf.edapt.spi.migration.Type; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Type</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.emf.edapt.spi.migration.impl.TypeImpl#getEClass <em>EClass</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.spi.migration.impl.TypeImpl#getInstances <em>Instances</em>}</li> |
| * <li>{@link org.eclipse.emf.edapt.spi.migration.impl.TypeImpl#getModel <em>Model</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class TypeImpl extends EObjectImpl implements Type { |
| /** |
| * The cached value of the '{@link #getEClass() <em>EClass</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getEClass() |
| * @generated |
| * @ordered |
| */ |
| protected EClass eClass; |
| |
| /** |
| * The cached value of the '{@link #getInstances() <em>Instances</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getInstances() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Instance> instances; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected TypeImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return MigrationPackage.Literals.TYPE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EClass getEClass() { |
| if (eClass != null && eClass.eIsProxy()) { |
| final InternalEObject oldEClass = (InternalEObject) eClass; |
| eClass = (EClass) eResolveProxy(oldEClass); |
| if (eClass != oldEClass) { |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, MigrationPackage.TYPE__ECLASS, oldEClass, |
| eClass)); |
| } |
| } |
| } |
| return eClass; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public EClass basicGetEClass() { |
| return eClass; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setEClass(EClass newEClass) { |
| final EClass oldEClass = eClass; |
| eClass = newEClass; |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, MigrationPackage.TYPE__ECLASS, oldEClass, eClass)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EList<Instance> getInstances() { |
| if (instances == null) { |
| instances = new EObjectContainmentWithInverseEList<Instance>(Instance.class, this, |
| MigrationPackage.TYPE__INSTANCES, MigrationPackage.INSTANCE__TYPE); |
| } |
| return instances; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Model getModel() { |
| if (eContainerFeatureID() != MigrationPackage.TYPE__MODEL) { |
| return null; |
| } |
| return (Model) eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public NotificationChain basicSetModel(Model newModel, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject) newModel, MigrationPackage.TYPE__MODEL, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void setModel(Model newModel) { |
| if (newModel != eInternalContainer() |
| || eContainerFeatureID() != MigrationPackage.TYPE__MODEL && newModel != null) { |
| if (EcoreUtil.isAncestor(this, (EObject) newModel)) { |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ |
| } |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) { |
| msgs = eBasicRemoveFromContainer(msgs); |
| } |
| if (newModel != null) { |
| msgs = ((InternalEObject) newModel).eInverseAdd(this, MigrationPackage.MODEL__TYPES, Model.class, msgs); |
| } |
| msgs = basicSetModel(newModel, msgs); |
| if (msgs != null) { |
| msgs.dispatch(); |
| } |
| } |
| else if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, MigrationPackage.TYPE__MODEL, newModel, newModel)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated NOT |
| */ |
| @Override |
| public Instance newInstance() { |
| final Instance instance = MigrationFactory.eINSTANCE.createInstance(); |
| getInstances().add(instance); |
| return instance; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case MigrationPackage.TYPE__INSTANCES: |
| return ((InternalEList<InternalEObject>) (InternalEList<?>) getInstances()).basicAdd(otherEnd, msgs); |
| case MigrationPackage.TYPE__MODEL: |
| if (eInternalContainer() != null) { |
| msgs = eBasicRemoveFromContainer(msgs); |
| } |
| return basicSetModel((Model) 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.TYPE__INSTANCES: |
| return ((InternalEList<?>) getInstances()).basicRemove(otherEnd, msgs); |
| case MigrationPackage.TYPE__MODEL: |
| return basicSetModel(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.TYPE__MODEL: |
| return eInternalContainer().eInverseRemove(this, MigrationPackage.MODEL__TYPES, Model.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.TYPE__ECLASS: |
| if (resolve) { |
| return getEClass(); |
| } |
| return basicGetEClass(); |
| case MigrationPackage.TYPE__INSTANCES: |
| return getInstances(); |
| case MigrationPackage.TYPE__MODEL: |
| return getModel(); |
| } |
| 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 MigrationPackage.TYPE__ECLASS: |
| setEClass((EClass) newValue); |
| return; |
| case MigrationPackage.TYPE__INSTANCES: |
| getInstances().clear(); |
| getInstances().addAll((Collection<? extends Instance>) newValue); |
| return; |
| case MigrationPackage.TYPE__MODEL: |
| setModel((Model) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case MigrationPackage.TYPE__ECLASS: |
| setEClass((EClass) null); |
| return; |
| case MigrationPackage.TYPE__INSTANCES: |
| getInstances().clear(); |
| return; |
| case MigrationPackage.TYPE__MODEL: |
| setModel((Model) null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MigrationPackage.TYPE__ECLASS: |
| return eClass != null; |
| case MigrationPackage.TYPE__INSTANCES: |
| return instances != null && !instances.isEmpty(); |
| case MigrationPackage.TYPE__MODEL: |
| return getModel() != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| } // TypeImpl |