blob: 7372118db3be3a0f2a87c8ba2b432fe6269f117e [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013, 2018 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.codegen.qvticgmodel.impl;
import java.util.Collection;
import java.util.List;
import java.util.Map;
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.EClassifier;
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.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.codegen.cgmodel.CGAccumulator;
import org.eclipse.ocl.examples.codegen.cgmodel.CGElement;
import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement;
import org.eclipse.ocl.examples.codegen.cgmodel.impl.CGValuedElementImpl;
import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor;
import org.eclipse.ocl.examples.codegen.cse.AbstractPlace;
import org.eclipse.ocl.pivot.ids.TypeId;
import org.eclipse.qvtd.codegen.qvti.cse.MappingExpPlaces;
import org.eclipse.qvtd.codegen.qvticgmodel.CGMappingExp;
import org.eclipse.qvtd.codegen.qvticgmodel.QVTiCGModelPackage;
import org.eclipse.qvtd.codegen.qvticgmodel.util.QVTiCGModelVisitor;
import org.eclipse.qvtd.codegen.utilities.QVTiEquivalenceUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>CG Mapping Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGMappingExpImpl#getOwnedAccumulators <em>Owned Accumulators</em>}</li>
* <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGMappingExpImpl#getOwnedBody <em>Owned Body</em>}</li>
* </ul>
*
* @generated
*/
public class CGMappingExpImpl extends CGValuedElementImpl implements CGMappingExp {
/**
* The number of structural features of the '<em>CG Mapping Exp</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int CG_MAPPING_EXP_FEATURE_COUNT = CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 2;
/**
* The cached value of the '{@link #getOwnedAccumulators() <em>Owned Accumulators</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedAccumulators()
* @generated
* @ordered
*/
protected EList<CGAccumulator> ownedAccumulators;
/**
* The cached value of the '{@link #getOwnedBody() <em>Owned Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedBody()
* @generated
* @ordered
*/
protected CGValuedElement ownedBody;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGMappingExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return QVTiCGModelPackage.Literals.CG_MAPPING_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<CGAccumulator> getOwnedAccumulators() {
if (ownedAccumulators == null) {
ownedAccumulators = new EObjectContainmentEList<CGAccumulator>(CGAccumulator.class, this, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0);
}
return ownedAccumulators;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGValuedElement getOwnedBody() {
return ownedBody;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedBody(CGValuedElement newOwnedBody, NotificationChain msgs) {
CGValuedElement oldOwnedBody = ownedBody;
ownedBody = newOwnedBody;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1, oldOwnedBody, newOwnedBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwnedBody(CGValuedElement newOwnedBody) {
if (newOwnedBody != ownedBody) {
NotificationChain msgs = null;
if (ownedBody != null)
msgs = ((InternalEObject)ownedBody).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1), null, msgs);
if (newOwnedBody != null)
msgs = ((InternalEObject)newOwnedBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1), null, msgs);
msgs = basicSetOwnedBody(newOwnedBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1, newOwnedBody, newOwnedBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
return ((InternalEList<?>)getOwnedAccumulators()).basicRemove(otherEnd, msgs);
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
return basicSetOwnedBody(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 CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
return getOwnedAccumulators();
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
return getOwnedBody();
}
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 CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
getOwnedAccumulators().clear();
getOwnedAccumulators().addAll((Collection<? extends CGAccumulator>)newValue);
return;
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
setOwnedBody((CGValuedElement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
getOwnedAccumulators().clear();
return;
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
setOwnedBody((CGValuedElement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
return ownedAccumulators != null && !ownedAccumulators.isEmpty();
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
return ownedBody != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return (R) ((QVTiCGModelVisitor<?>)visitor).visitCGMappingExp(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable TypeId getASTypeId() {
return TypeId.BOOLEAN;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable EClassifier getEcoreClassifier() {
return null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable AbstractPlace getPlace(@NonNull Map<@Nullable CGElement, @NonNull AbstractPlace> element2place) {
return MappingExpPlaces.createMappingExpPlaces(element2place, this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isBoxed() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isEcore() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
return (getClass() == thatValue.getClass()) ? QVTiEquivalenceUtil.isEquivalent(this, (CGMappingExp)thatValue) : null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUnboxed() {
return true;
}
} //CGMappingExpImpl