| /** |
| * * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro |
| * * 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: |
| * * Istvan Rath, Daniel Varro - initial API and implementation |
| * |
| */ |
| package org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.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.EObjectWithInverseResolvingEList; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.compoundRules.BlockRule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.compoundRules.CompoundRulesPackage; |
| |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.core.impl.GTASMElementImpl; |
| |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.DefinitionsPackage; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.TypeConstant; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Variable; |
| |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.terms.TermsPackage; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.terms.VariableReference; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Variable</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.VariableImpl#getReferences <em>References</em>}</li> |
| * <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.VariableImpl#getScope <em>Scope</em>}</li> |
| * <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.VariableImpl#getVariableType <em>Variable Type</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class VariableImpl extends GTASMElementImpl implements Variable |
| { |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static final String copyright = " * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors:\r\n * Istvan Rath, Daniel Varro - initial API and implementation\r\n"; |
| |
| /** |
| * The cached value of the '{@link #getReferences() <em>References</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getReferences() |
| * @generated |
| * @ordered |
| */ |
| protected EList<VariableReference> references; |
| |
| /** |
| * The cached value of the '{@link #getVariableType() <em>Variable Type</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getVariableType() |
| * @generated |
| * @ordered |
| */ |
| protected TypeConstant variableType; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected VariableImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return DefinitionsPackage.Literals.VARIABLE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<VariableReference> getReferences() |
| { |
| if (references == null) |
| { |
| references = new EObjectWithInverseResolvingEList<VariableReference>(VariableReference.class, this, DefinitionsPackage.VARIABLE__REFERENCES, TermsPackage.VARIABLE_REFERENCE__VARIABLE); |
| } |
| return references; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public BlockRule getScope() |
| { |
| if (eContainerFeatureID() != DefinitionsPackage.VARIABLE__SCOPE) return null; |
| return (BlockRule)eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetScope(BlockRule newScope, NotificationChain msgs) |
| { |
| msgs = eBasicSetContainer((InternalEObject)newScope, DefinitionsPackage.VARIABLE__SCOPE, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setScope(BlockRule newScope) |
| { |
| if (newScope != eInternalContainer() || (eContainerFeatureID() != DefinitionsPackage.VARIABLE__SCOPE && newScope != null)) |
| { |
| if (EcoreUtil.isAncestor(this, newScope)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newScope != null) |
| msgs = ((InternalEObject)newScope).eInverseAdd(this, CompoundRulesPackage.BLOCK_RULE__LOCAL_VARIABLES, BlockRule.class, msgs); |
| msgs = basicSetScope(newScope, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.VARIABLE__SCOPE, newScope, newScope)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TypeConstant getVariableType() |
| { |
| return variableType; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetVariableType(TypeConstant newVariableType, NotificationChain msgs) |
| { |
| TypeConstant oldVariableType = variableType; |
| variableType = newVariableType; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DefinitionsPackage.VARIABLE__VARIABLE_TYPE, oldVariableType, newVariableType); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setVariableType(TypeConstant newVariableType) |
| { |
| if (newVariableType != variableType) |
| { |
| NotificationChain msgs = null; |
| if (variableType != null) |
| msgs = ((InternalEObject)variableType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DefinitionsPackage.VARIABLE__VARIABLE_TYPE, null, msgs); |
| if (newVariableType != null) |
| msgs = ((InternalEObject)newVariableType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DefinitionsPackage.VARIABLE__VARIABLE_TYPE, null, msgs); |
| msgs = basicSetVariableType(newVariableType, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.VARIABLE__VARIABLE_TYPE, newVariableType, newVariableType)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case DefinitionsPackage.VARIABLE__REFERENCES: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getReferences()).basicAdd(otherEnd, msgs); |
| case DefinitionsPackage.VARIABLE__SCOPE: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetScope((BlockRule)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 DefinitionsPackage.VARIABLE__REFERENCES: |
| return ((InternalEList<?>)getReferences()).basicRemove(otherEnd, msgs); |
| case DefinitionsPackage.VARIABLE__SCOPE: |
| return basicSetScope(null, msgs); |
| case DefinitionsPackage.VARIABLE__VARIABLE_TYPE: |
| return basicSetVariableType(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) |
| { |
| switch (eContainerFeatureID()) |
| { |
| case DefinitionsPackage.VARIABLE__SCOPE: |
| return eInternalContainer().eInverseRemove(this, CompoundRulesPackage.BLOCK_RULE__LOCAL_VARIABLES, BlockRule.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 DefinitionsPackage.VARIABLE__REFERENCES: |
| return getReferences(); |
| case DefinitionsPackage.VARIABLE__SCOPE: |
| return getScope(); |
| case DefinitionsPackage.VARIABLE__VARIABLE_TYPE: |
| return getVariableType(); |
| } |
| 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 DefinitionsPackage.VARIABLE__REFERENCES: |
| getReferences().clear(); |
| getReferences().addAll((Collection<? extends VariableReference>)newValue); |
| return; |
| case DefinitionsPackage.VARIABLE__SCOPE: |
| setScope((BlockRule)newValue); |
| return; |
| case DefinitionsPackage.VARIABLE__VARIABLE_TYPE: |
| setVariableType((TypeConstant)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case DefinitionsPackage.VARIABLE__REFERENCES: |
| getReferences().clear(); |
| return; |
| case DefinitionsPackage.VARIABLE__SCOPE: |
| setScope((BlockRule)null); |
| return; |
| case DefinitionsPackage.VARIABLE__VARIABLE_TYPE: |
| setVariableType((TypeConstant)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case DefinitionsPackage.VARIABLE__REFERENCES: |
| return references != null && !references.isEmpty(); |
| case DefinitionsPackage.VARIABLE__SCOPE: |
| return getScope() != null; |
| case DefinitionsPackage.VARIABLE__VARIABLE_TYPE: |
| return variableType != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| } //VariableImpl |