blob: 76d9c22cd96a737ae812c84734a7558638e9931e [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2014, 2016 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.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.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
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.CGCallable;
import org.eclipse.ocl.examples.codegen.cgmodel.CGElement;
import org.eclipse.ocl.examples.codegen.cgmodel.CGModelPackage;
import org.eclipse.ocl.examples.codegen.cgmodel.CGParameter;
import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement;
import org.eclipse.ocl.examples.codegen.cse.AbstractPlace;
import org.eclipse.ocl.examples.codegen.cse.OuterStackPlace;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>CG Callable</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGCallableImpl#getParameters <em>Parameters</em>}</li>
* <li>{@link org.eclipse.ocl.examples.codegen.cgmodel.impl.CGCallableImpl#getBody <em>Body</em>}</li>
* </ul>
*
* @generated
*/
public abstract class CGCallableImpl extends CGValuedElementImpl implements CGCallable {
/**
* The cached value of the '{@link #getParameters() <em>Parameters</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParameters()
* @generated
* @ordered
*/
protected EList<CGParameter> parameters;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected CGValuedElement body;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGCallableImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CGModelPackage.Literals.CG_CALLABLE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("null")
@Override
public @NonNull List<CGParameter> getParameters() {
if (parameters == null) {
parameters = new EObjectContainmentWithInverseEList<CGParameter>(CGParameter.class, this, CGModelPackage.CG_CALLABLE__PARAMETERS, CGModelPackage.CG_PARAMETER__CALLABLE);
}
return parameters;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGValuedElement getBody() {
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBody(CGValuedElement newBody, NotificationChain msgs) {
CGValuedElement oldBody = body;
body = newBody;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_CALLABLE__BODY, oldBody, newBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setBody(CGValuedElement newBody) {
if (newBody != body) {
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CGModelPackage.CG_CALLABLE__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CGModelPackage.CG_CALLABLE__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CGModelPackage.CG_CALLABLE__BODY, newBody, newBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CGModelPackage.CG_CALLABLE__PARAMETERS:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getParameters()).basicAdd(otherEnd, 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_CALLABLE__PARAMETERS:
return ((InternalEList<?>)getParameters()).basicRemove(otherEnd, msgs);
case CGModelPackage.CG_CALLABLE__BODY:
return basicSetBody(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_CALLABLE__PARAMETERS:
return getParameters();
case CGModelPackage.CG_CALLABLE__BODY:
return getBody();
}
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 CGModelPackage.CG_CALLABLE__PARAMETERS:
getParameters().clear();
getParameters().addAll((Collection<? extends CGParameter>)newValue);
return;
case CGModelPackage.CG_CALLABLE__BODY:
setBody((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_CALLABLE__PARAMETERS:
getParameters().clear();
return;
case CGModelPackage.CG_CALLABLE__BODY:
setBody((CGValuedElement)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CGModelPackage.CG_CALLABLE__PARAMETERS:
return parameters != null && !parameters.isEmpty();
case CGModelPackage.CG_CALLABLE__BODY:
return body != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable AbstractPlace getPlace(@NonNull Map<@Nullable CGElement, @NonNull AbstractPlace> element2place) {
return OuterStackPlace.createOuterStackPlace(element2place, this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isContext() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
throw new UnsupportedOperationException(getClass().getName() + ".isEquivalentToInternal()");
}
} //CGCallableImpl