blob: 1761d4766c0f29add4194dfa6ba1991eb0e0ea36 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2014, 2019 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*******************************************************************************/
package org.eclipse.qvtd.xtext.qvtimperativecs.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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.xtext.basecs.PathNameCS;
import org.eclipse.ocl.xtext.basecs.impl.ModelElementCSImpl;
import org.eclipse.ocl.xtext.basecs.util.BaseCSVisitor;
import org.eclipse.ocl.xtext.essentialoclcs.ExpCS;
import org.eclipse.ocl.xtext.essentialoclcs.VariableCS;
import org.eclipse.qvtd.xtext.qvtimperativecs.MappingLoopCS;
import org.eclipse.qvtd.xtext.qvtimperativecs.MappingStatementCS;
import org.eclipse.qvtd.xtext.qvtimperativecs.ObservableStatementCS;
import org.eclipse.qvtd.xtext.qvtimperativecs.QVTimperativeCSPackage;
import org.eclipse.qvtd.xtext.qvtimperativecs.util.QVTimperativeCSVisitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Mapping Loop CS</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvtd.xtext.qvtimperativecs.impl.MappingLoopCSImpl#getObservedProperties <em>Observed Properties</em>}</li>
* <li>{@link org.eclipse.qvtd.xtext.qvtimperativecs.impl.MappingLoopCSImpl#getOwnedIterator <em>Owned Iterator</em>}</li>
* <li>{@link org.eclipse.qvtd.xtext.qvtimperativecs.impl.MappingLoopCSImpl#getOwnedInExpression <em>Owned In Expression</em>}</li>
* <li>{@link org.eclipse.qvtd.xtext.qvtimperativecs.impl.MappingLoopCSImpl#getOwnedMappingStatements <em>Owned Mapping Statements</em>}</li>
* </ul>
*
* @generated
*/
public class MappingLoopCSImpl extends MappingStatementCSImpl implements MappingLoopCS {
/**
* The number of structural features of the '<em>Mapping Loop CS</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int MAPPING_LOOP_CS_FEATURE_COUNT = MappingStatementCSImpl.MAPPING_STATEMENT_CS_FEATURE_COUNT + 4;
/**
* The cached value of the '{@link #getObservedProperties() <em>Observed Properties</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getObservedProperties()
* @generated
* @ordered
*/
protected EList<PathNameCS> observedProperties;
/**
* The cached value of the '{@link #getOwnedIterator() <em>Owned Iterator</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedIterator()
* @generated
* @ordered
*/
protected VariableCS ownedIterator;
/**
* The cached value of the '{@link #getOwnedInExpression() <em>Owned In Expression</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedInExpression()
* @generated
* @ordered
*/
protected ExpCS ownedInExpression;
/**
* The cached value of the '{@link #getOwnedMappingStatements() <em>Owned Mapping Statements</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedMappingStatements()
* @generated
* @ordered
*/
protected EList<MappingStatementCS> ownedMappingStatements;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MappingLoopCSImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return QVTimperativeCSPackage.Literals.MAPPING_LOOP_CS;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<PathNameCS> getObservedProperties() {
if (observedProperties == null) {
observedProperties = new EObjectContainmentEList<PathNameCS>(PathNameCS.class, this, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0);
}
return observedProperties;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public VariableCS getOwnedIterator() {
return ownedIterator;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedIterator(VariableCS newOwnedIterator, NotificationChain msgs) {
VariableCS oldOwnedIterator = ownedIterator;
ownedIterator = newOwnedIterator;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1, oldOwnedIterator, newOwnedIterator);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwnedIterator(VariableCS newOwnedIterator) {
if (newOwnedIterator != ownedIterator) {
NotificationChain msgs = null;
if (ownedIterator != null)
msgs = ((InternalEObject)ownedIterator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1), null, msgs);
if (newOwnedIterator != null)
msgs = ((InternalEObject)newOwnedIterator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1), null, msgs);
msgs = basicSetOwnedIterator(newOwnedIterator, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1, newOwnedIterator, newOwnedIterator));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public ExpCS getOwnedInExpression() {
return ownedInExpression;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedInExpression(ExpCS newOwnedInExpression, NotificationChain msgs) {
ExpCS oldOwnedInExpression = ownedInExpression;
ownedInExpression = newOwnedInExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2, oldOwnedInExpression, newOwnedInExpression);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwnedInExpression(ExpCS newOwnedInExpression) {
if (newOwnedInExpression != ownedInExpression) {
NotificationChain msgs = null;
if (ownedInExpression != null)
msgs = ((InternalEObject)ownedInExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2), null, msgs);
if (newOwnedInExpression != null)
msgs = ((InternalEObject)newOwnedInExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2), null, msgs);
msgs = basicSetOwnedInExpression(newOwnedInExpression, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2, newOwnedInExpression, newOwnedInExpression));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<MappingStatementCS> getOwnedMappingStatements() {
if (ownedMappingStatements == null) {
ownedMappingStatements = new EObjectContainmentEList<MappingStatementCS>(MappingStatementCS.class, this, ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3);
}
return ownedMappingStatements;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0:
return ((InternalEList<?>)getObservedProperties()).basicRemove(otherEnd, msgs);
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1:
return basicSetOwnedIterator(null, msgs);
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2:
return basicSetOwnedInExpression(null, msgs);
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3:
return ((InternalEList<?>)getOwnedMappingStatements()).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 ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0:
return getObservedProperties();
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1:
return getOwnedIterator();
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2:
return getOwnedInExpression();
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3:
return getOwnedMappingStatements();
}
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 ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0:
getObservedProperties().clear();
getObservedProperties().addAll((Collection<? extends PathNameCS>)newValue);
return;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1:
setOwnedIterator((VariableCS)newValue);
return;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2:
setOwnedInExpression((ExpCS)newValue);
return;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3:
getOwnedMappingStatements().clear();
getOwnedMappingStatements().addAll((Collection<? extends MappingStatementCS>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0:
getObservedProperties().clear();
return;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1:
setOwnedIterator((VariableCS)null);
return;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2:
setOwnedInExpression((ExpCS)null);
return;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3:
getOwnedMappingStatements().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0:
return observedProperties != null && !observedProperties.isEmpty();
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 1:
return ownedIterator != null;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 2:
return ownedInExpression != null;
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 3:
return ownedMappingStatements != null && !ownedMappingStatements.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == ObservableStatementCS.class) {
switch (derivedFeatureID) {
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0: return ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0;
default: return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
if (baseClass == ObservableStatementCS.class) {
switch (baseFeatureID) {
case ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0: return ModelElementCSImpl.MODEL_ELEMENT_CS_FEATURE_COUNT + 0;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(@NonNull BaseCSVisitor<R> visitor) {
return (R) ((QVTimperativeCSVisitor<?>)visitor).visitMappingLoopCS(this);
}
} //MappingLoopCSImpl