blob: 548c6c7415b97c4d35046487b60590f693f00641 [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 org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
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.edapt.spi.migration.Metamodel;
import org.eclipse.emf.edapt.spi.migration.MigrationPackage;
import org.eclipse.emf.edapt.spi.migration.Model;
import org.eclipse.emf.edapt.spi.migration.Repository;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Repository</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.edapt.spi.migration.impl.RepositoryImpl#getModel <em>Model</em>}</li>
* <li>{@link org.eclipse.emf.edapt.spi.migration.impl.RepositoryImpl#getMetamodel <em>Metamodel</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class RepositoryImpl extends EObjectImpl implements Repository {
/**
* The cached value of the '{@link #getModel() <em>Model</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getModel()
* @generated
* @ordered
*/
protected Model model;
/**
* The cached value of the '{@link #getMetamodel() <em>Metamodel</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getMetamodel()
* @generated
* @ordered
*/
protected Metamodel metamodel;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected RepositoryImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return MigrationPackage.Literals.REPOSITORY;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public Model getModel() {
return model;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetModel(Model newModel, NotificationChain msgs) {
final Model oldModel = model;
model = newModel;
if (eNotificationRequired()) {
final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
MigrationPackage.REPOSITORY__MODEL, oldModel, newModel);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setModel(Model newModel) {
if (newModel != model) {
NotificationChain msgs = null;
if (model != null) {
msgs = ((InternalEObject) model).eInverseRemove(this, MigrationPackage.MODEL__REPOSITORY, Model.class,
msgs);
}
if (newModel != null) {
msgs = ((InternalEObject) newModel).eInverseAdd(this, MigrationPackage.MODEL__REPOSITORY, Model.class,
msgs);
}
msgs = basicSetModel(newModel, msgs);
if (msgs != null) {
msgs.dispatch();
}
}
else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, MigrationPackage.REPOSITORY__MODEL, newModel,
newModel));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public Metamodel getMetamodel() {
return metamodel;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetMetamodel(Metamodel newMetamodel, NotificationChain msgs) {
final Metamodel oldMetamodel = metamodel;
metamodel = newMetamodel;
if (eNotificationRequired()) {
final ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
MigrationPackage.REPOSITORY__METAMODEL, oldMetamodel, newMetamodel);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setMetamodel(Metamodel newMetamodel) {
if (newMetamodel != metamodel) {
NotificationChain msgs = null;
if (metamodel != null) {
msgs = ((InternalEObject) metamodel).eInverseRemove(this, MigrationPackage.METAMODEL__REPOSITORY,
Metamodel.class, msgs);
}
if (newMetamodel != null) {
msgs = ((InternalEObject) newMetamodel).eInverseAdd(this, MigrationPackage.METAMODEL__REPOSITORY,
Metamodel.class, msgs);
}
msgs = basicSetMetamodel(newMetamodel, msgs);
if (msgs != null) {
msgs.dispatch();
}
}
else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, MigrationPackage.REPOSITORY__METAMODEL, newMetamodel,
newMetamodel));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MigrationPackage.REPOSITORY__MODEL:
if (model != null) {
msgs = ((InternalEObject) model).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- MigrationPackage.REPOSITORY__MODEL, null, msgs);
}
return basicSetModel((Model) otherEnd, msgs);
case MigrationPackage.REPOSITORY__METAMODEL:
if (metamodel != null) {
msgs = ((InternalEObject) metamodel).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- MigrationPackage.REPOSITORY__METAMODEL, null, msgs);
}
return basicSetMetamodel((Metamodel) 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.REPOSITORY__MODEL:
return basicSetModel(null, msgs);
case MigrationPackage.REPOSITORY__METAMODEL:
return basicSetMetamodel(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case MigrationPackage.REPOSITORY__MODEL:
return getModel();
case MigrationPackage.REPOSITORY__METAMODEL:
return getMetamodel();
}
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.REPOSITORY__MODEL:
setModel((Model) newValue);
return;
case MigrationPackage.REPOSITORY__METAMODEL:
setMetamodel((Metamodel) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MigrationPackage.REPOSITORY__MODEL:
setModel((Model) null);
return;
case MigrationPackage.REPOSITORY__METAMODEL:
setMetamodel((Metamodel) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MigrationPackage.REPOSITORY__MODEL:
return model != null;
case MigrationPackage.REPOSITORY__METAMODEL:
return metamodel != null;
}
return super.eIsSet(featureID);
}
} // RepositoryImpl