| /******************************************************************************* |
| * Copyright (c) 2011, 2019 Willink Transformations and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * E.D.Willink - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.qvtd.pivot.qvtrelation.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.emf.ecore.util.EcoreUtil; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| import org.eclipse.qvtd.pivot.qvtbase.impl.DomainImpl; |
| import org.eclipse.qvtd.pivot.qvtbase.impl.PatternImpl; |
| import org.eclipse.qvtd.pivot.qvtrelation.DomainPattern; |
| import org.eclipse.qvtd.pivot.qvtrelation.QVTrelationPackage; |
| import org.eclipse.qvtd.pivot.qvtrelation.RelationDomain; |
| import org.eclipse.qvtd.pivot.qvtrelation.util.QVTrelationVisitor; |
| import org.eclipse.qvtd.pivot.qvttemplate.TemplateExp; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Domain Pattern</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtrelation.impl.DomainPatternImpl#getRelationDomain <em>Relation Domain</em>}</li> |
| * <li>{@link org.eclipse.qvtd.pivot.qvtrelation.impl.DomainPatternImpl#getTemplateExpression <em>Template Expression</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class DomainPatternImpl extends PatternImpl implements DomainPattern { |
| /** |
| * The number of structural features of the '<em>Domain Pattern</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int DOMAIN_PATTERN_FEATURE_COUNT = PatternImpl.PATTERN_FEATURE_COUNT + 2; |
| /** |
| * The number of operations of the '<em>Domain Pattern</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int DOMAIN_PATTERN_OPERATION_COUNT = PatternImpl.PATTERN_OPERATION_COUNT + 0; |
| /** |
| * The cached value of the '{@link #getTemplateExpression() <em>Template Expression</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTemplateExpression() |
| * @generated |
| * @ordered |
| */ |
| protected TemplateExp templateExpression; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DomainPatternImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return QVTrelationPackage.Literals.DOMAIN_PATTERN; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public RelationDomain getRelationDomain() { |
| if (eContainerFeatureID() != (PatternImpl.PATTERN_FEATURE_COUNT + 0)) return null; |
| return (RelationDomain)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetRelationDomain(RelationDomain newRelationDomain, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newRelationDomain, PatternImpl.PATTERN_FEATURE_COUNT + 0, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setRelationDomain(RelationDomain newRelationDomain) { |
| if (newRelationDomain != eInternalContainer() || (eContainerFeatureID() != (PatternImpl.PATTERN_FEATURE_COUNT + 0) && newRelationDomain != null)) { |
| if (EcoreUtil.isAncestor(this, newRelationDomain)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newRelationDomain != null) |
| msgs = ((InternalEObject)newRelationDomain).eInverseAdd(this, DomainImpl.DOMAIN_FEATURE_COUNT + 1, RelationDomain.class, msgs); |
| msgs = basicSetRelationDomain(newRelationDomain, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, PatternImpl.PATTERN_FEATURE_COUNT + 0, newRelationDomain, newRelationDomain)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public TemplateExp getTemplateExpression() { |
| return templateExpression; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetTemplateExpression(TemplateExp newTemplateExpression, NotificationChain msgs) { |
| TemplateExp oldTemplateExpression = templateExpression; |
| templateExpression = newTemplateExpression; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PatternImpl.PATTERN_FEATURE_COUNT + 1, oldTemplateExpression, newTemplateExpression); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setTemplateExpression(TemplateExp newTemplateExpression) { |
| if (newTemplateExpression != templateExpression) { |
| NotificationChain msgs = null; |
| if (templateExpression != null) |
| msgs = ((InternalEObject)templateExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (PatternImpl.PATTERN_FEATURE_COUNT + 1), null, msgs); |
| if (newTemplateExpression != null) |
| msgs = ((InternalEObject)newTemplateExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (PatternImpl.PATTERN_FEATURE_COUNT + 1), null, msgs); |
| msgs = basicSetTemplateExpression(newTemplateExpression, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, PatternImpl.PATTERN_FEATURE_COUNT + 1, newTemplateExpression, newTemplateExpression)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case PatternImpl.PATTERN_FEATURE_COUNT + 0: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetRelationDomain((RelationDomain)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 PatternImpl.PATTERN_FEATURE_COUNT + 0: |
| return basicSetRelationDomain(null, msgs); |
| case PatternImpl.PATTERN_FEATURE_COUNT + 1: |
| return basicSetTemplateExpression(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case PatternImpl.PATTERN_FEATURE_COUNT + 0: |
| return eInternalContainer().eInverseRemove(this, DomainImpl.DOMAIN_FEATURE_COUNT + 1, RelationDomain.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 PatternImpl.PATTERN_FEATURE_COUNT + 0: |
| return getRelationDomain(); |
| case PatternImpl.PATTERN_FEATURE_COUNT + 1: |
| return getTemplateExpression(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case PatternImpl.PATTERN_FEATURE_COUNT + 0: |
| setRelationDomain((RelationDomain)newValue); |
| return; |
| case PatternImpl.PATTERN_FEATURE_COUNT + 1: |
| setTemplateExpression((TemplateExp)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case PatternImpl.PATTERN_FEATURE_COUNT + 0: |
| setRelationDomain((RelationDomain)null); |
| return; |
| case PatternImpl.PATTERN_FEATURE_COUNT + 1: |
| setTemplateExpression((TemplateExp)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case PatternImpl.PATTERN_FEATURE_COUNT + 0: |
| return getRelationDomain() != null; |
| case PatternImpl.PATTERN_FEATURE_COUNT + 1: |
| return templateExpression != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| if (visitor instanceof QVTrelationVisitor) { |
| return (R) ((QVTrelationVisitor<?>)visitor).visitDomainPattern(this); |
| } |
| else { |
| return super.accept(visitor); |
| } |
| } |
| } //DomainPatternImpl |