/******************************************************************************* * Copyright (c) 2013, 2015 CEA LIST 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: * 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 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, CGModelPackage.CG_LET_EXP__INIT, 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 - CGModelPackage.CG_LET_EXP__INIT, null, msgs); if (newInit != null) msgs = ((InternalEObject)newInit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CGModelPackage.CG_LET_EXP__INIT, null, msgs); msgs = basicSetInit(newInit, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_LET_EXP__INIT, 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, CGModelPackage.CG_LET_EXP__IN, 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 - CGModelPackage.CG_LET_EXP__IN, null, msgs); if (newIn != null) msgs = ((InternalEObject)newIn).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CGModelPackage.CG_LET_EXP__IN, null, msgs); msgs = basicSetIn(newIn, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_LET_EXP__IN, newIn, newIn)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case CGModelPackage.CG_LET_EXP__INIT: return basicSetInit(null, msgs); case CGModelPackage.CG_LET_EXP__IN: 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 CGModelPackage.CG_LET_EXP__INIT: return getInit(); case CGModelPackage.CG_LET_EXP__IN: 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 CGModelPackage.CG_LET_EXP__INIT: setInit((CGVariable)newValue); return; case CGModelPackage.CG_LET_EXP__IN: setIn((CGValuedElement)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case CGModelPackage.CG_LET_EXP__INIT: setInit((CGVariable)null); return; case CGModelPackage.CG_LET_EXP__IN: setIn((CGValuedElement)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case CGModelPackage.CG_LET_EXP__INIT: return init != null; case CGModelPackage.CG_LET_EXP__IN: 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<CGElement,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