| /******************************************************************************* |
| * Copyright (c) 2011, 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.pivot.qvtbase.impl; |
| |
| import java.util.Map; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.common.util.Diagnostic; |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| 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.pivot.OCLExpression; |
| import org.eclipse.ocl.pivot.Parameter; |
| import org.eclipse.ocl.pivot.PivotPackage; |
| import org.eclipse.ocl.pivot.Variable; |
| import org.eclipse.ocl.pivot.internal.ParameterImpl; |
| import org.eclipse.ocl.pivot.util.PivotValidator; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| import org.eclipse.qvtd.pivot.qvtbase.FunctionParameter; |
| import org.eclipse.qvtd.pivot.qvtbase.QVTbasePackage; |
| import org.eclipse.qvtd.pivot.qvtbase.util.QVTbaseVisitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Function Parameter</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtbase.impl.FunctionParameterImpl#isIsImplicit <em>Is Implicit</em>}</li> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtbase.impl.FunctionParameterImpl#getOwnedInit <em>Owned Init</em>}</li> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtbase.impl.FunctionParameterImpl#getRepresentedParameter <em>Represented Parameter</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class FunctionParameterImpl extends ParameterImpl implements FunctionParameter { |
| /** |
| * The default value of the '{@link #isIsImplicit() <em>Is Implicit</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isIsImplicit() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean IS_IMPLICIT_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isIsImplicit() <em>Is Implicit</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isIsImplicit() |
| * @generated |
| * @ordered |
| */ |
| protected boolean isImplicit = IS_IMPLICIT_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getOwnedInit() <em>Owned Init</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedInit() |
| * @generated |
| * @ordered |
| */ |
| protected OCLExpression ownedInit; |
| |
| /** |
| * The cached value of the '{@link #getRepresentedParameter() <em>Represented Parameter</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getRepresentedParameter() |
| * @generated |
| * @ordered |
| */ |
| protected Parameter representedParameter; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected FunctionParameterImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return QVTbasePackage.Literals.FUNCTION_PARAMETER; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Parameter getRepresentedParameter() { |
| if (representedParameter != null && representedParameter.eIsProxy()) { |
| InternalEObject oldRepresentedParameter = (InternalEObject)representedParameter; |
| representedParameter = (Parameter)eResolveProxy(oldRepresentedParameter); |
| if (representedParameter != oldRepresentedParameter) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER, oldRepresentedParameter, representedParameter)); |
| } |
| } |
| return representedParameter; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Parameter basicGetRepresentedParameter() { |
| return representedParameter; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setRepresentedParameter(Parameter newRepresentedParameter) { |
| Parameter oldRepresentedParameter = representedParameter; |
| representedParameter = newRepresentedParameter; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER, oldRepresentedParameter, representedParameter)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean isIsImplicit() { |
| return isImplicit; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setIsImplicit(boolean newIsImplicit) { |
| boolean oldIsImplicit = isImplicit; |
| isImplicit = newIsImplicit; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, QVTbasePackage.FUNCTION_PARAMETER__IS_IMPLICIT, oldIsImplicit, isImplicit)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public OCLExpression getOwnedInit() { |
| return ownedInit; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedInit(OCLExpression newOwnedInit, NotificationChain msgs) { |
| OCLExpression oldOwnedInit = ownedInit; |
| ownedInit = newOwnedInit; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT, oldOwnedInit, newOwnedInit); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedInit(OCLExpression newOwnedInit) { |
| if (newOwnedInit != ownedInit) { |
| NotificationChain msgs = null; |
| if (ownedInit != null) |
| msgs = ((InternalEObject)ownedInit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT, null, msgs); |
| if (newOwnedInit != null) |
| msgs = ((InternalEObject)newOwnedInit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT, null, msgs); |
| msgs = basicSetOwnedInit(newOwnedInit, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT, newOwnedInit, newOwnedInit)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| return super.toString(); |
| } |
| |
| /** |
| * The cached validation expression for the '{@link #validateCompatibleInitialiserType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Validate Compatible Initialiser Type</em>}' invariant operation. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #validateCompatibleInitialiserType(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| * @generated |
| * @ordered |
| */ |
| protected static final String VALIDATE_COMPATIBLE_INITIALISER_TYPE_DIAGNOSTIC_CHAIN_MAP__EEXPRESSION = "ownedInit <> null implies ownedInit?.type?.conformsTo(type)\n" + //$NON-NLS-1$ |
| "\n" + //$NON-NLS-1$ |
| ""; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean validateCompatibleInitialiserType(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| return |
| PivotValidator.validate |
| (QVTbasePackage.Literals.FUNCTION_PARAMETER, |
| this, |
| diagnostics, |
| context, |
| "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", |
| PivotPackage.Literals.VARIABLE___VALIDATE_COMPATIBLE_INITIALISER_TYPE__DIAGNOSTICCHAIN_MAP, |
| VALIDATE_COMPATIBLE_INITIALISER_TYPE_DIAGNOSTIC_CHAIN_MAP__EEXPRESSION, |
| Diagnostic.ERROR, |
| PivotValidator.DIAGNOSTIC_SOURCE, |
| PivotValidator.VARIABLE__VALIDATE_COMPATIBLE_INITIALISER_TYPE); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT: |
| return basicSetOwnedInit(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 QVTbasePackage.FUNCTION_PARAMETER__IS_IMPLICIT: |
| return isIsImplicit(); |
| case QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT: |
| return getOwnedInit(); |
| case QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER: |
| if (resolve) return getRepresentedParameter(); |
| return basicGetRepresentedParameter(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case QVTbasePackage.FUNCTION_PARAMETER__IS_IMPLICIT: |
| setIsImplicit((Boolean)newValue); |
| return; |
| case QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT: |
| setOwnedInit((OCLExpression)newValue); |
| return; |
| case QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER: |
| setRepresentedParameter((Parameter)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case QVTbasePackage.FUNCTION_PARAMETER__IS_IMPLICIT: |
| setIsImplicit(IS_IMPLICIT_EDEFAULT); |
| return; |
| case QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT: |
| setOwnedInit((OCLExpression)null); |
| return; |
| case QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER: |
| setRepresentedParameter((Parameter)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case QVTbasePackage.FUNCTION_PARAMETER__IS_IMPLICIT: |
| return isImplicit != IS_IMPLICIT_EDEFAULT; |
| case QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT: |
| return ownedInit != null; |
| case QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER: |
| return representedParameter != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == Variable.class) { |
| switch (derivedFeatureID) { |
| case QVTbasePackage.FUNCTION_PARAMETER__IS_IMPLICIT: return PivotPackage.VARIABLE__IS_IMPLICIT; |
| case QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT: return PivotPackage.VARIABLE__OWNED_INIT; |
| case QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER: return PivotPackage.VARIABLE__REPRESENTED_PARAMETER; |
| default: return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| if (baseClass == Variable.class) { |
| switch (baseFeatureID) { |
| case PivotPackage.VARIABLE__IS_IMPLICIT: return QVTbasePackage.FUNCTION_PARAMETER__IS_IMPLICIT; |
| case PivotPackage.VARIABLE__OWNED_INIT: return QVTbasePackage.FUNCTION_PARAMETER__OWNED_INIT; |
| case PivotPackage.VARIABLE__REPRESENTED_PARAMETER: return QVTbasePackage.FUNCTION_PARAMETER__REPRESENTED_PARAMETER; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public @Nullable <R> R accept(@NonNull Visitor<R> visitor) { |
| return (R) ((QVTbaseVisitor<?>)visitor).visitFunctionParameter(this); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public OCLExpression createInitExpression(EClass eClass) { |
| // TODO Auto-generated method stub |
| return null; |
| } |
| } //FunctionParameterImpl |