| /******************************************************************************* |
| * Copyright (c) 2013, 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.codegen.qvticgmodel.impl; |
| |
| import java.util.Collection; |
| import java.util.List; |
| 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.EClassifier; |
| 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.EcoreUtil; |
| 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.CGExecutorType; |
| import org.eclipse.ocl.examples.codegen.cgmodel.impl.CGNamedElementImpl; |
| import org.eclipse.ocl.examples.codegen.cgmodel.impl.CGValuedElementImpl; |
| import org.eclipse.ocl.examples.codegen.cgmodel.impl.CGVariableImpl; |
| import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor; |
| import org.eclipse.qvtd.codegen.qvticgmodel.CGMapping; |
| import org.eclipse.qvtd.codegen.qvticgmodel.CGRealizedVariable; |
| import org.eclipse.qvtd.codegen.qvticgmodel.CGRealizedVariablePart; |
| import org.eclipse.qvtd.codegen.qvticgmodel.CGTypedModel; |
| import org.eclipse.qvtd.codegen.qvticgmodel.QVTiCGModelPackage; |
| import org.eclipse.qvtd.codegen.qvticgmodel.util.QVTiCGModelVisitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>CG Realized Variable</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGRealizedVariableImpl#getExecutorType <em>Executor Type</em>}</li> |
| * <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGRealizedVariableImpl#getOwningMapping <em>Owning Mapping</em>}</li> |
| * <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGRealizedVariableImpl#getTypedModel <em>Typed Model</em>}</li> |
| * <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGRealizedVariableImpl#getOwnedParts <em>Owned Parts</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class CGRealizedVariableImpl extends CGVariableImpl implements CGRealizedVariable { |
| /** |
| * The number of structural features of the '<em>CG Realized Variable</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int CG_REALIZED_VARIABLE_FEATURE_COUNT = CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 4; |
| |
| /** |
| * The cached value of the '{@link #getExecutorType() <em>Executor Type</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getExecutorType() |
| * @generated |
| * @ordered |
| */ |
| protected CGExecutorType executorType; |
| |
| /** |
| * The cached value of the '{@link #getTypedModel() <em>Typed Model</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTypedModel() |
| * @generated |
| * @ordered |
| */ |
| protected CGTypedModel typedModel; |
| |
| /** |
| * The cached value of the '{@link #getOwnedParts() <em>Owned Parts</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedParts() |
| * @generated |
| * @ordered |
| */ |
| protected EList<CGRealizedVariablePart> ownedParts; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected CGRealizedVariableImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return QVTiCGModelPackage.Literals.CG_REALIZED_VARIABLE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public CGTypedModel getTypedModel() { |
| return typedModel; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setTypedModel(CGTypedModel newTypedModel) { |
| CGTypedModel oldTypedModel = typedModel; |
| typedModel = newTypedModel; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 2, oldTypedModel, typedModel)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public List<CGRealizedVariablePart> getOwnedParts() { |
| if (ownedParts == null) { |
| ownedParts = new EObjectContainmentWithInverseEList<CGRealizedVariablePart>(CGRealizedVariablePart.class, this, CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 3, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0); |
| } |
| return ownedParts; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetOwningMapping((CGMapping)otherEnd, msgs); |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 3: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedParts()).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 CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1: |
| return basicSetOwningMapping(null, msgs); |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 3: |
| return ((InternalEList<?>)getOwnedParts()).basicRemove(otherEnd, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1: |
| return eInternalContainer().eInverseRemove(this, CGNamedElementImpl.CG_NAMED_ELEMENT_FEATURE_COUNT + 4, CGMapping.class, msgs); |
| } |
| return super.eBasicRemoveFromContainerFeature(msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public CGExecutorType getExecutorType() { |
| return executorType; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setExecutorType(CGExecutorType newExecutorType) { |
| CGExecutorType oldExecutorType = executorType; |
| executorType = newExecutorType; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 0, oldExecutorType, executorType)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public CGMapping getOwningMapping() { |
| if (eContainerFeatureID() != (CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1)) return null; |
| return (CGMapping)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwningMapping(CGMapping newOwningMapping, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newOwningMapping, CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwningMapping(CGMapping newOwningMapping) { |
| if (newOwningMapping != eInternalContainer() || (eContainerFeatureID() != (CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1) && newOwningMapping != null)) { |
| if (EcoreUtil.isAncestor(this, newOwningMapping)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newOwningMapping != null) |
| msgs = ((InternalEObject)newOwningMapping).eInverseAdd(this, CGNamedElementImpl.CG_NAMED_ELEMENT_FEATURE_COUNT + 4, CGMapping.class, msgs); |
| msgs = basicSetOwningMapping(newOwningMapping, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1, newOwningMapping, newOwningMapping)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 0: |
| return getExecutorType(); |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1: |
| return getOwningMapping(); |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 2: |
| return getTypedModel(); |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 3: |
| return getOwnedParts(); |
| } |
| 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 CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 0: |
| setExecutorType((CGExecutorType)newValue); |
| return; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1: |
| setOwningMapping((CGMapping)newValue); |
| return; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 2: |
| setTypedModel((CGTypedModel)newValue); |
| return; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 3: |
| getOwnedParts().clear(); |
| getOwnedParts().addAll((Collection<? extends CGRealizedVariablePart>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 0: |
| setExecutorType((CGExecutorType)null); |
| return; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1: |
| setOwningMapping((CGMapping)null); |
| return; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 2: |
| setTypedModel((CGTypedModel)null); |
| return; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 3: |
| getOwnedParts().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 0: |
| return executorType != null; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 1: |
| return getOwningMapping() != null; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 2: |
| return typedModel != null; |
| case CGVariableImpl.CG_VARIABLE_FEATURE_COUNT + 3: |
| return ownedParts != null && !ownedParts.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public <R> R accept(@NonNull CGModelVisitor<R> visitor) { |
| if (visitor instanceof QVTiCGModelVisitor) { |
| return (R) ((QVTiCGModelVisitor<?>)visitor).visitCGRealizedVariable(this); |
| } |
| else { |
| return super.accept(visitor); |
| } |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public @Nullable EClassifier getEcoreClassifier() { |
| return null; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isAssertedNonNull() { |
| return false; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isBoxed() { |
| return false; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isEcore() { |
| return false; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isGlobal() { |
| return false; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isNonNull() { |
| return true; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isNull() { |
| return false; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public boolean isUnboxed() { |
| return true; |
| } |
| |
| } //CGRealizedVariableImpl |