blob: 9916651e7ff5170a5b8fb8702286783f22ebbf4e [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Willink Transformations 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:
* Adolfo Sanchez-Barbudo Herrera - initial API and implementation
*******************************************************************************/
/**
*/
package org.eclipse.qvtd.doc.miniocl.impl;
import java.util.Collection;
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.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.qvtd.doc.miniocl.ExpressionInOCL;
import org.eclipse.qvtd.doc.miniocl.MiniOCLPackage;
import org.eclipse.qvtd.doc.miniocl.Operation;
import org.eclipse.qvtd.doc.miniocl.Parameter;
import org.eclipse.qvtd.doc.miniocl.util.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Operation</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvtd.doc.miniocl.impl.OperationImpl#getOwnedParameters <em>Owned Parameters</em>}</li>
* <li>{@link org.eclipse.qvtd.doc.miniocl.impl.OperationImpl#getOwnedBodyExpression <em>Owned Body Expression</em>}</li>
* <li>{@link org.eclipse.qvtd.doc.miniocl.impl.OperationImpl#getOwningClass <em>Owning Class</em>}</li>
* </ul>
*
* @generated
*/
public class OperationImpl extends FeatureImpl implements Operation {
/**
* The cached value of the '{@link #getOwnedParameters() <em>Owned Parameters</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedParameters()
* @generated
* @ordered
*/
protected EList<Parameter> ownedParameters;
/**
* The cached value of the '{@link #getOwnedBodyExpression() <em>Owned Body Expression</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedBodyExpression()
* @generated
* @ordered
*/
protected ExpressionInOCL ownedBodyExpression;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected OperationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return MiniOCLPackage.Literals.OPERATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Parameter> getOwnedParameters() {
if (ownedParameters == null) {
ownedParameters = new EObjectContainmentEList<Parameter>(Parameter.class, this, MiniOCLPackage.OPERATION__OWNED_PARAMETERS);
}
return ownedParameters;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public org.eclipse.qvtd.doc.miniocl.Class getOwningClass() {
if (eContainerFeatureID() != MiniOCLPackage.OPERATION__OWNING_CLASS) return null;
return (org.eclipse.qvtd.doc.miniocl.Class)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwningClass(org.eclipse.qvtd.doc.miniocl.Class newOwningClass, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newOwningClass, MiniOCLPackage.OPERATION__OWNING_CLASS, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOwningClass(org.eclipse.qvtd.doc.miniocl.Class newOwningClass) {
if (newOwningClass != eInternalContainer() || (eContainerFeatureID() != MiniOCLPackage.OPERATION__OWNING_CLASS && newOwningClass != null)) {
if (EcoreUtil.isAncestor(this, newOwningClass))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newOwningClass != null)
msgs = ((InternalEObject)newOwningClass).eInverseAdd(this, MiniOCLPackage.CLASS__OWNED_OPERATIONS, org.eclipse.qvtd.doc.miniocl.Class.class, msgs);
msgs = basicSetOwningClass(newOwningClass, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MiniOCLPackage.OPERATION__OWNING_CLASS, newOwningClass, newOwningClass));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ExpressionInOCL getOwnedBodyExpression() {
return ownedBodyExpression;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedBodyExpression(ExpressionInOCL newOwnedBodyExpression, NotificationChain msgs) {
ExpressionInOCL oldOwnedBodyExpression = ownedBodyExpression;
ownedBodyExpression = newOwnedBodyExpression;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION, oldOwnedBodyExpression, newOwnedBodyExpression);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOwnedBodyExpression(ExpressionInOCL newOwnedBodyExpression) {
if (newOwnedBodyExpression != ownedBodyExpression) {
NotificationChain msgs = null;
if (ownedBodyExpression != null)
msgs = ((InternalEObject)ownedBodyExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION, null, msgs);
if (newOwnedBodyExpression != null)
msgs = ((InternalEObject)newOwnedBodyExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION, null, msgs);
msgs = basicSetOwnedBodyExpression(newOwnedBodyExpression, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION, newOwnedBodyExpression, newOwnedBodyExpression));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case MiniOCLPackage.OPERATION__OWNING_CLASS:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwningClass((org.eclipse.qvtd.doc.miniocl.Class)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 MiniOCLPackage.OPERATION__OWNED_PARAMETERS:
return ((InternalEList<?>)getOwnedParameters()).basicRemove(otherEnd, msgs);
case MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION:
return basicSetOwnedBodyExpression(null, msgs);
case MiniOCLPackage.OPERATION__OWNING_CLASS:
return basicSetOwningClass(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case MiniOCLPackage.OPERATION__OWNING_CLASS:
return eInternalContainer().eInverseRemove(this, MiniOCLPackage.CLASS__OWNED_OPERATIONS, org.eclipse.qvtd.doc.miniocl.Class.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 MiniOCLPackage.OPERATION__OWNED_PARAMETERS:
return getOwnedParameters();
case MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION:
return getOwnedBodyExpression();
case MiniOCLPackage.OPERATION__OWNING_CLASS:
return getOwningClass();
}
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 MiniOCLPackage.OPERATION__OWNED_PARAMETERS:
getOwnedParameters().clear();
getOwnedParameters().addAll((Collection<? extends Parameter>)newValue);
return;
case MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION:
setOwnedBodyExpression((ExpressionInOCL)newValue);
return;
case MiniOCLPackage.OPERATION__OWNING_CLASS:
setOwningClass((org.eclipse.qvtd.doc.miniocl.Class)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case MiniOCLPackage.OPERATION__OWNED_PARAMETERS:
getOwnedParameters().clear();
return;
case MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION:
setOwnedBodyExpression((ExpressionInOCL)null);
return;
case MiniOCLPackage.OPERATION__OWNING_CLASS:
setOwningClass((org.eclipse.qvtd.doc.miniocl.Class)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case MiniOCLPackage.OPERATION__OWNED_PARAMETERS:
return ownedParameters != null && !ownedParameters.isEmpty();
case MiniOCLPackage.OPERATION__OWNED_BODY_EXPRESSION:
return ownedBodyExpression != null;
case MiniOCLPackage.OPERATION__OWNING_CLASS:
return getOwningClass() != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
return visitor.visitOperation(this);
}
} //OperationImpl