blob: 963e80c2bcd1b4c609cb4d73cd6620bdefbe2fd4 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013, 2019 CEA LIST 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(CEA LIST) - Initial API and implementation
*******************************************************************************/
package org.eclipse.ocl.examples.codegen.cgmodel.impl;
import java.util.Map;
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.EClassifier;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.codegen.cgmodel.CGElement;
import org.eclipse.ocl.examples.codegen.cgmodel.CGLetExp;
import org.eclipse.ocl.examples.codegen.cgmodel.CGModelPackage;
import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement;
import org.eclipse.ocl.examples.codegen.cgmodel.CGVariable;
import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor;
import org.eclipse.ocl.examples.codegen.cse.AbstractPlace;
import org.eclipse.ocl.examples.codegen.cse.LetPlaces;
import org.eclipse.ocl.examples.codegen.utilities.EquivalenceUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>CG Let Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGLetExpImpl#getInit <em>Init</em>}</li>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGLetExpImpl#getIn <em>In</em>}</li>
* </ul>
*
* @generated
*/
public class CGLetExpImpl extends CGValuedElementImpl implements CGLetExp {
/**
* The number of structural features of the '<em>CG Let Exp</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int CG_LET_EXP_FEATURE_COUNT = CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 2;
/**
* The cached value of the '{@link #getInit() <em>Init</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInit()
* @generated
* @ordered
*/
protected CGVariable init;
/**
* The cached value of the '{@link #getIn() <em>In</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIn()
* @generated
* @ordered
*/
protected CGValuedElement in;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGLetExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CGModelPackage.Literals.CG_LET_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGVariable getInit() {
return init;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetInit(CGVariable newInit, NotificationChain msgs) {
CGVariable oldInit = init;
init = newInit;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 6, oldInit, newInit);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setInit(CGVariable newInit) {
if (newInit != init) {
NotificationChain msgs = null;
if (init != null)
msgs = ((InternalEObject)init).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (6), null, msgs);
if (newInit != null)
msgs = ((InternalEObject)newInit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (6), null, msgs);
msgs = basicSetInit(newInit, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 6, newInit, newInit));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGValuedElement getIn() {
return in;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetIn(CGValuedElement newIn, NotificationChain msgs) {
CGValuedElement oldIn = in;
in = newIn;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 7, oldIn, newIn);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setIn(CGValuedElement newIn) {
if (newIn != in) {
NotificationChain msgs = null;
if (in != null)
msgs = ((InternalEObject)in).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (7), null, msgs);
if (newIn != null)
msgs = ((InternalEObject)newIn).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (7), null, msgs);
msgs = basicSetIn(newIn, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, 7, newIn, newIn));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case 6:
return basicSetInit(null, msgs);
case 7:
return basicSetIn(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 6:
return getInit();
case 7:
return getIn();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case 6:
setInit((CGVariable)newValue);
return;
case 7:
setIn((CGValuedElement)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case 6:
setInit((CGVariable)null);
return;
case 7:
setIn((CGValuedElement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case 6:
return init != null;
case 7:
return in != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return visitor.visitCGLetExp(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable EClassifier getEcoreClassifier() {
return in != null ? in.getEcoreClassifier() : null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable AbstractPlace getPlace(@NonNull Map<@Nullable CGElement, @NonNull AbstractPlace> element2place) {
return LetPlaces.createLetPlaces(element2place, this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @NonNull CGValuedElement getReferredValue() {
return in != null ? in : this;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @NonNull CGValuedElement getSourceValue() {
return in != null ? in.getSourceValue() : this;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @NonNull CGValuedElement getNamedValue() {
return in != null ? in.getNamedValue() : this;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @NonNull CGValuedElement getTypedValue() {
return in != null ? in.getTypedValue() : this;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable String getValueName() {
return in != null ? in.getValueName() : null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isBoxed() {
return (in != null) && in.isBoxed();
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isEcore() {
return (in != null) && in.isEcore();
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
return (getClass() == thatValue.getClass()) ? EquivalenceUtil.isEquivalent(this, (CGLetExp)thatValue) : null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isGlobal() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUnboxed() {
return (in != null) && in.isUnboxed();
}
} //CGLetExpImpl