| /******************************************************************************* |
| * Copyright (c) 2012, 2015 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: |
| * E.D.Willink - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.qvtd.xtext.qvtcorebasecs.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.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.xtext.basecs.PathNameCS; |
| import org.eclipse.ocl.xtext.basecs.impl.TypedElementCSImpl; |
| import org.eclipse.ocl.xtext.basecs.util.BaseCSVisitor; |
| import org.eclipse.ocl.xtext.essentialoclcs.ExpCS; |
| import org.eclipse.qvtd.pivot.qvtbase.Transformation; |
| import org.eclipse.qvtd.xtext.qvtcorebasecs.ParamDeclarationCS; |
| import org.eclipse.qvtd.xtext.qvtcorebasecs.QVTcoreBaseCSPackage; |
| import org.eclipse.qvtd.xtext.qvtcorebasecs.QueryCS; |
| import org.eclipse.qvtd.xtext.qvtcorebasecs.util.QVTcoreBaseCSVisitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Query CS</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.qvtd.xtext.qvtcorebasecs.impl.QueryCSImpl#getOwnedPathName <em>Owned Path Name</em>}</li> |
| * <li>{@link org.eclipse.qvtd.xtext.qvtcorebasecs.impl.QueryCSImpl#getTransformation <em>Transformation</em>}</li> |
| * <li>{@link org.eclipse.qvtd.xtext.qvtcorebasecs.impl.QueryCSImpl#getOwnedParameters <em>Owned Parameters</em>}</li> |
| * <li>{@link org.eclipse.qvtd.xtext.qvtcorebasecs.impl.QueryCSImpl#getOwnedExpression <em>Owned Expression</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class QueryCSImpl extends TypedElementCSImpl implements QueryCS { |
| /** |
| * The cached value of the '{@link #getOwnedPathName() <em>Owned Path Name</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedPathName() |
| * @generated |
| * @ordered |
| */ |
| protected PathNameCS ownedPathName; |
| |
| /** |
| * 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<ParamDeclarationCS> ownedParameters; |
| |
| /** |
| * The cached value of the '{@link #getOwnedExpression() <em>Owned Expression</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedExpression() |
| * @generated |
| * @ordered |
| */ |
| protected ExpCS ownedExpression; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected QueryCSImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return QVTcoreBaseCSPackage.Literals.QUERY_CS; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public PathNameCS getOwnedPathName() { |
| return ownedPathName; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedPathName(PathNameCS newOwnedPathName, NotificationChain msgs) { |
| PathNameCS oldOwnedPathName = ownedPathName; |
| ownedPathName = newOwnedPathName; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME, oldOwnedPathName, newOwnedPathName); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedPathName(PathNameCS newOwnedPathName) { |
| if (newOwnedPathName != ownedPathName) { |
| NotificationChain msgs = null; |
| if (ownedPathName != null) |
| msgs = ((InternalEObject)ownedPathName).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME, null, msgs); |
| if (newOwnedPathName != null) |
| msgs = ((InternalEObject)newOwnedPathName).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME, null, msgs); |
| msgs = basicSetOwnedPathName(newOwnedPathName, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME, newOwnedPathName, newOwnedPathName)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME: |
| return basicSetOwnedPathName(null, msgs); |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PARAMETERS: |
| return ((InternalEList<?>)getOwnedParameters()).basicRemove(otherEnd, msgs); |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION: |
| return basicSetOwnedExpression(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 QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME: |
| return getOwnedPathName(); |
| case QVTcoreBaseCSPackage.QUERY_CS__TRANSFORMATION: |
| return getTransformation(); |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PARAMETERS: |
| return getOwnedParameters(); |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION: |
| return getOwnedExpression(); |
| } |
| 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 QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME: |
| setOwnedPathName((PathNameCS)newValue); |
| return; |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PARAMETERS: |
| getOwnedParameters().clear(); |
| getOwnedParameters().addAll((Collection<? extends ParamDeclarationCS>)newValue); |
| return; |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION: |
| setOwnedExpression((ExpCS)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME: |
| setOwnedPathName((PathNameCS)null); |
| return; |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PARAMETERS: |
| getOwnedParameters().clear(); |
| return; |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION: |
| setOwnedExpression((ExpCS)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PATH_NAME: |
| return ownedPathName != null; |
| case QVTcoreBaseCSPackage.QUERY_CS__TRANSFORMATION: |
| return getTransformation() != null; |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_PARAMETERS: |
| return ownedParameters != null && !ownedParameters.isEmpty(); |
| case QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION: |
| return ownedExpression != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public <R> R accept(@NonNull BaseCSVisitor<R> visitor) { |
| return (R) ((QVTcoreBaseCSVisitor<?>)visitor).visitQueryCS(this); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public Transformation getTransformation() { |
| if (ownedPathName == null) { |
| return null; |
| } |
| return (Transformation) ownedPathName.getReferredElement(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<ParamDeclarationCS> getOwnedParameters() { |
| if (ownedParameters == null) { |
| ownedParameters = new EObjectContainmentEList<ParamDeclarationCS>(ParamDeclarationCS.class, this, QVTcoreBaseCSPackage.QUERY_CS__OWNED_PARAMETERS); |
| } |
| return ownedParameters; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public ExpCS getOwnedExpression() { |
| return ownedExpression; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedExpression(ExpCS newOwnedExpression, NotificationChain msgs) { |
| ExpCS oldOwnedExpression = ownedExpression; |
| ownedExpression = newOwnedExpression; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION, oldOwnedExpression, newOwnedExpression); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedExpression(ExpCS newOwnedExpression) { |
| if (newOwnedExpression != ownedExpression) { |
| NotificationChain msgs = null; |
| if (ownedExpression != null) |
| msgs = ((InternalEObject)ownedExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION, null, msgs); |
| if (newOwnedExpression != null) |
| msgs = ((InternalEObject)newOwnedExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION, null, msgs); |
| msgs = basicSetOwnedExpression(newOwnedExpression, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, QVTcoreBaseCSPackage.QUERY_CS__OWNED_EXPRESSION, newOwnedExpression, newOwnedExpression)); |
| } |
| } //QueryCSImpl |