blob: 9daff6742a6a6f2b22b18cfe466253905d5cfa91 [file] [log] [blame]
/**
* Copyright (c) 2020 CEA LIST.
*
* 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\n\nContributors:
* Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
* - Initial API and Implementation
*/
package org.eclipse.efm.ecore.formalml.infrastructure.impl;
import java.util.Collection;
import org.eclipse.efm.ecore.formalml.common.impl.TypedElementImpl;
import org.eclipse.efm.ecore.formalml.infrastructure.InfrastructurePackage;
import org.eclipse.efm.ecore.formalml.infrastructure.InstanceMachine;
import org.eclipse.efm.ecore.formalml.infrastructure.Machine;
import org.eclipse.efm.ecore.formalml.infrastructure.Modifier;
import org.eclipse.efm.ecore.formalml.infrastructure.SlotProperty;
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.InternalEList;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Instance Machine</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.InstanceMachineImpl#getModifier <em>Modifier</em>}</li>
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.InstanceMachineImpl#getModel <em>Model</em>}</li>
* <li>{@link org.eclipse.efm.ecore.formalml.infrastructure.impl.InstanceMachineImpl#getSlot <em>Slot</em>}</li>
* </ul>
*
* @generated
*/
public class InstanceMachineImpl extends TypedElementImpl implements InstanceMachine {
/**
* The cached value of the '{@link #getModifier() <em>Modifier</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getModifier()
* @generated
* @ordered
*/
protected Modifier modifier;
/**
* The cached value of the '{@link #getModel() <em>Model</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getModel()
* @generated
* @ordered
*/
protected Machine model;
/**
* The cached value of the '{@link #getSlot() <em>Slot</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSlot()
* @generated
* @ordered
*/
protected EList<SlotProperty> slot;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected InstanceMachineImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return InfrastructurePackage.Literals.INSTANCE_MACHINE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Modifier getModifier() {
return modifier;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetModifier(Modifier newModifier, NotificationChain msgs) {
Modifier oldModifier = modifier;
modifier = newModifier;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InfrastructurePackage.INSTANCE_MACHINE__MODIFIER, oldModifier, newModifier);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setModifier(Modifier newModifier) {
if (newModifier != modifier) {
NotificationChain msgs = null;
if (modifier != null)
msgs = ((InternalEObject)modifier).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.INSTANCE_MACHINE__MODIFIER, null, msgs);
if (newModifier != null)
msgs = ((InternalEObject)newModifier).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InfrastructurePackage.INSTANCE_MACHINE__MODIFIER, null, msgs);
msgs = basicSetModifier(newModifier, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InfrastructurePackage.INSTANCE_MACHINE__MODIFIER, newModifier, newModifier));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Machine getModel() {
if (model != null && model.eIsProxy()) {
InternalEObject oldModel = (InternalEObject)model;
model = (Machine)eResolveProxy(oldModel);
if (model != oldModel) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, InfrastructurePackage.INSTANCE_MACHINE__MODEL, oldModel, model));
}
}
return model;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Machine basicGetModel() {
return model;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setModel(Machine newModel) {
Machine oldModel = model;
model = newModel;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InfrastructurePackage.INSTANCE_MACHINE__MODEL, oldModel, model));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<SlotProperty> getSlot() {
if (slot == null) {
slot = new EObjectContainmentEList<SlotProperty>(SlotProperty.class, this, InfrastructurePackage.INSTANCE_MACHINE__SLOT);
}
return slot;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case InfrastructurePackage.INSTANCE_MACHINE__MODIFIER:
return basicSetModifier(null, msgs);
case InfrastructurePackage.INSTANCE_MACHINE__SLOT:
return ((InternalEList<?>)getSlot()).basicRemove(otherEnd, 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 InfrastructurePackage.INSTANCE_MACHINE__MODIFIER:
return getModifier();
case InfrastructurePackage.INSTANCE_MACHINE__MODEL:
if (resolve) return getModel();
return basicGetModel();
case InfrastructurePackage.INSTANCE_MACHINE__SLOT:
return getSlot();
}
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 InfrastructurePackage.INSTANCE_MACHINE__MODIFIER:
setModifier((Modifier)newValue);
return;
case InfrastructurePackage.INSTANCE_MACHINE__MODEL:
setModel((Machine)newValue);
return;
case InfrastructurePackage.INSTANCE_MACHINE__SLOT:
getSlot().clear();
getSlot().addAll((Collection<? extends SlotProperty>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case InfrastructurePackage.INSTANCE_MACHINE__MODIFIER:
setModifier((Modifier)null);
return;
case InfrastructurePackage.INSTANCE_MACHINE__MODEL:
setModel((Machine)null);
return;
case InfrastructurePackage.INSTANCE_MACHINE__SLOT:
getSlot().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case InfrastructurePackage.INSTANCE_MACHINE__MODIFIER:
return modifier != null;
case InfrastructurePackage.INSTANCE_MACHINE__MODEL:
return model != null;
case InfrastructurePackage.INSTANCE_MACHINE__SLOT:
return slot != null && !slot.isEmpty();
}
return super.eIsSet(featureID);
}
} //InstanceMachineImpl