blob: a8e9e4461df863a0d19246c9cf0e86e50ca5b6ac [file] [log] [blame]
/*******************************************************************************
* 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.CGShadowExp;
import org.eclipse.ocl.examples.codegen.cgmodel.CGShadowPart;
import org.eclipse.ocl.examples.codegen.cgmodel.CGExecutorShadowPart;
import org.eclipse.ocl.examples.codegen.cgmodel.CGModelPackage;
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 Constructor Part</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGShadowPartImpl#getInit <em>Init</em>}</li>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGShadowPartImpl#getShadowExp <em>Shadow Exp</em>}</li>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGShadowPartImpl#getExecutorPart <em>Executor Part</em>}</li>
* </ul>
*
* @generated
*/
public class CGShadowPartImpl extends CGValuedElementImpl implements CGShadowPart {
/**
* 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;
/**
* The cached value of the '{@link #getExecutorPart() <em>Executor Part</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getExecutorPart()
* @generated
* @ordered
*/
protected CGExecutorShadowPart executorPart;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGShadowPartImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CGModelPackage.Literals.CG_SHADOW_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_SHADOW_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_SHADOW_PART__INIT, null, msgs);
if (newInit != null)
msgs = ((InternalEObject)newInit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CGModelPackage.CG_SHADOW_PART__INIT, null, msgs);
msgs = basicSetInit(newInit, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_SHADOW_PART__INIT, newInit, newInit));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGShadowExp getShadowExp() {
if (eContainerFeatureID() != CGModelPackage.CG_SHADOW_PART__SHADOW_EXP) return null;
return (CGShadowExp)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGExecutorShadowPart getExecutorPart() {
return executorPart;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setExecutorPart(CGExecutorShadowPart newExecutorPart) {
CGExecutorShadowPart oldExecutorPart = executorPart;
executorPart = newExecutorPart;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_SHADOW_PART__EXECUTOR_PART, oldExecutorPart, executorPart));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CGModelPackage.CG_SHADOW_PART__SHADOW_EXP:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return eBasicSetContainer(otherEnd, CGModelPackage.CG_SHADOW_PART__SHADOW_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_SHADOW_PART__INIT:
return basicSetInit(null, msgs);
case CGModelPackage.CG_SHADOW_PART__SHADOW_EXP:
return eBasicSetContainer(null, CGModelPackage.CG_SHADOW_PART__SHADOW_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_SHADOW_PART__SHADOW_EXP:
return eInternalContainer().eInverseRemove(this, CGModelPackage.CG_SHADOW_EXP__PARTS, CGShadowExp.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_SHADOW_PART__INIT:
return getInit();
case CGModelPackage.CG_SHADOW_PART__SHADOW_EXP:
return getShadowExp();
case CGModelPackage.CG_SHADOW_PART__EXECUTOR_PART:
return getExecutorPart();
}
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_SHADOW_PART__INIT:
setInit((CGValuedElement)newValue);
return;
case CGModelPackage.CG_SHADOW_PART__EXECUTOR_PART:
setExecutorPart((CGExecutorShadowPart)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CGModelPackage.CG_SHADOW_PART__INIT:
setInit((CGValuedElement)null);
return;
case CGModelPackage.CG_SHADOW_PART__EXECUTOR_PART:
setExecutorPart((CGExecutorShadowPart)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CGModelPackage.CG_SHADOW_PART__INIT:
return init != null;
case CGModelPackage.CG_SHADOW_PART__SHADOW_EXP:
return getShadowExp() != null;
case CGModelPackage.CG_SHADOW_PART__EXECUTOR_PART:
return executorPart != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return visitor.visitCGShadowPart(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isBoxed() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isCommonable() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isConstant() {
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, (CGShadowPart)thatValue) : null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isGlobal() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUnboxed() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean rewriteAs(@NonNull CGValuedElement oldValue, @NonNull CGValuedElement newValue) {
if (oldValue == executorPart) {
setExecutorPart((CGExecutorShadowPart)newValue);
return true;
}
return false;
}
} //CGConstructorPartImpl