/******************************************************************************* * 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 org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; 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.CGModelPackage; import org.eclipse.ocl.examples.codegen.cgmodel.CGTupleExp; import org.eclipse.ocl.examples.codegen.cgmodel.CGTuplePart; import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement; import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor; import org.eclipse.ocl.examples.codegen.utilities.EquivalenceUtil; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>CG Tuple Part</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGTuplePartImpl#getInit <em>Init</em>}</li> * <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGTuplePartImpl#getTupleExp <em>Tuple Exp</em>}</li> * </ul> * * @generated */ public class CGTuplePartImpl extends CGValuedElementImpl implements CGTuplePart { /** * The cached value of the '{@link #getInit() <em>Init</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getInit() * @generated * @ordered */ protected CGValuedElement init; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected CGTuplePartImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return CGModelPackage.Literals.CG_TUPLE_PART; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public CGValuedElement getInit() { return init; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetInit(CGValuedElement newInit, NotificationChain msgs) { CGValuedElement oldInit = init; init = newInit; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_TUPLE_PART__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(CGValuedElement newInit) { if (newInit != init) { NotificationChain msgs = null; if (init != null) msgs = ((InternalEObject)init).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CGModelPackage.CG_TUPLE_PART__INIT, null, msgs); if (newInit != null) msgs = ((InternalEObject)newInit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CGModelPackage.CG_TUPLE_PART__INIT, null, msgs); msgs = basicSetInit(newInit, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_TUPLE_PART__INIT, newInit, newInit)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public CGTupleExp getTupleExp() { if (eContainerFeatureID() != CGModelPackage.CG_TUPLE_PART__TUPLE_EXP) return null; return (CGTupleExp)eInternalContainer(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case CGModelPackage.CG_TUPLE_PART__TUPLE_EXP: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return eBasicSetContainer(otherEnd, CGModelPackage.CG_TUPLE_PART__TUPLE_EXP, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case CGModelPackage.CG_TUPLE_PART__INIT: return basicSetInit(null, msgs); case CGModelPackage.CG_TUPLE_PART__TUPLE_EXP: return eBasicSetContainer(null, CGModelPackage.CG_TUPLE_PART__TUPLE_EXP, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { switch (eContainerFeatureID()) { case CGModelPackage.CG_TUPLE_PART__TUPLE_EXP: return eInternalContainer().eInverseRemove(this, CGModelPackage.CG_TUPLE_EXP__PARTS, CGTupleExp.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case CGModelPackage.CG_TUPLE_PART__INIT: return getInit(); case CGModelPackage.CG_TUPLE_PART__TUPLE_EXP: return getTupleExp(); } 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_TUPLE_PART__INIT: setInit((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_TUPLE_PART__INIT: setInit((CGValuedElement)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case CGModelPackage.CG_TUPLE_PART__INIT: return init != null; case CGModelPackage.CG_TUPLE_PART__TUPLE_EXP: return getTupleExp() != null; } return super.eIsSet(featureID); } /** * {@inheritDoc} * @generated */ @Override public <R> R accept(@NonNull CGModelVisitor<R> visitor) { return visitor.visitCGTuplePart(this); } /** * {@inheritDoc} * @generated */ @Override public @NonNull CGValuedElement getNamedValue() { return init != null ? init.getNamedValue() : this; } /** * {@inheritDoc} * @generated */ @Override public @NonNull CGValuedElement getReferredValue() { return init != null ? init : this; } /** * {@inheritDoc} * @generated */ @Override public @NonNull CGValuedElement getSourceValue() { return init != null ? init.getSourceValue() : this; } /** * {@inheritDoc} * @generated */ @Override public @NonNull CGValuedElement getTypedValue() { return init != null ? init.getTypedValue() : this; } /** * {@inheritDoc} * @generated */ @Override public @Nullable String getValueName() { return init != null ? init.getValueName() : null; } /** * {@inheritDoc} * @generated */ @Override public boolean isBoxed() { return true; } /** * {@inheritDoc} * @generated */ @Override public boolean isCommonable() { return false; } /** * {@inheritDoc} * @generated */ @Override public boolean isEcore() { return false; } /** * {@inheritDoc} * @generated */ @Override public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) { return (getClass() == thatValue.getClass()) ? EquivalenceUtil.isEquivalent(this, (CGTuplePart)thatValue) : null; } /** * {@inheritDoc} * @generated */ @Override public boolean isInlined() { return true; } /** * {@inheritDoc} * @generated */ @Override public boolean isUnboxed() { return false; } } //CGTuplePartImpl