| /** |
| * * 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.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| 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.Machine; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Rule; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.SymbolicRuleParameter; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Variable; |
| |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.simpleRules.ASMRuleInvocation; |
| import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.simpleRules.SimpleRulesPackage; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Rule</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.RuleImpl#getBody <em>Body</em>}</li> |
| * <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.RuleImpl#getSymParameters <em>Sym Parameters</em>}</li> |
| * <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.RuleImpl#getLocalVariables <em>Local Variables</em>}</li> |
| * <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.RuleImpl#getNamespace <em>Namespace</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class RuleImpl extends GTASMElementImpl implements Rule |
| { |
| /** |
| * <!-- 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 #getBody() <em>Body</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getBody() |
| * @generated |
| * @ordered |
| */ |
| protected ASMRuleInvocation body; |
| |
| /** |
| * The cached value of the '{@link #getSymParameters() <em>Sym Parameters</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSymParameters() |
| * @generated |
| * @ordered |
| */ |
| protected EList<SymbolicRuleParameter> symParameters; |
| |
| /** |
| * The cached value of the '{@link #getLocalVariables() <em>Local Variables</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLocalVariables() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Variable> localVariables; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected RuleImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return DefinitionsPackage.Literals.RULE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ASMRuleInvocation getBody() |
| { |
| return body; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetBody(ASMRuleInvocation newBody, NotificationChain msgs) |
| { |
| ASMRuleInvocation oldBody = body; |
| body = newBody; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DefinitionsPackage.RULE__BODY, oldBody, newBody); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setBody(ASMRuleInvocation newBody) |
| { |
| if (newBody != body) |
| { |
| NotificationChain msgs = null; |
| if (body != null) |
| msgs = ((InternalEObject)body).eInverseRemove(this, SimpleRulesPackage.ASM_RULE_INVOCATION__ASM_RULE, ASMRuleInvocation.class, msgs); |
| if (newBody != null) |
| msgs = ((InternalEObject)newBody).eInverseAdd(this, SimpleRulesPackage.ASM_RULE_INVOCATION__ASM_RULE, ASMRuleInvocation.class, msgs); |
| msgs = basicSetBody(newBody, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.RULE__BODY, newBody, newBody)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<SymbolicRuleParameter> getSymParameters() |
| { |
| if (symParameters == null) |
| { |
| symParameters = new EObjectContainmentEList<SymbolicRuleParameter>(SymbolicRuleParameter.class, this, DefinitionsPackage.RULE__SYM_PARAMETERS); |
| } |
| return symParameters; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Variable> getLocalVariables() |
| { |
| if (localVariables == null) |
| { |
| localVariables = new EObjectContainmentEList<Variable>(Variable.class, this, DefinitionsPackage.RULE__LOCAL_VARIABLES); |
| } |
| return localVariables; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Machine getNamespace() |
| { |
| if (eContainerFeatureID() != DefinitionsPackage.RULE__NAMESPACE) return null; |
| return (Machine)eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetNamespace(Machine newNamespace, NotificationChain msgs) |
| { |
| msgs = eBasicSetContainer((InternalEObject)newNamespace, DefinitionsPackage.RULE__NAMESPACE, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setNamespace(Machine newNamespace) |
| { |
| if (newNamespace != eInternalContainer() || (eContainerFeatureID() != DefinitionsPackage.RULE__NAMESPACE && newNamespace != null)) |
| { |
| if (EcoreUtil.isAncestor(this, newNamespace)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newNamespace != null) |
| msgs = ((InternalEObject)newNamespace).eInverseAdd(this, DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS, Machine.class, msgs); |
| msgs = basicSetNamespace(newNamespace, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.RULE__NAMESPACE, newNamespace, newNamespace)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case DefinitionsPackage.RULE__BODY: |
| if (body != null) |
| msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DefinitionsPackage.RULE__BODY, null, msgs); |
| return basicSetBody((ASMRuleInvocation)otherEnd, msgs); |
| case DefinitionsPackage.RULE__NAMESPACE: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetNamespace((Machine)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.RULE__BODY: |
| return basicSetBody(null, msgs); |
| case DefinitionsPackage.RULE__SYM_PARAMETERS: |
| return ((InternalEList<?>)getSymParameters()).basicRemove(otherEnd, msgs); |
| case DefinitionsPackage.RULE__LOCAL_VARIABLES: |
| return ((InternalEList<?>)getLocalVariables()).basicRemove(otherEnd, msgs); |
| case DefinitionsPackage.RULE__NAMESPACE: |
| return basicSetNamespace(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.RULE__NAMESPACE: |
| return eInternalContainer().eInverseRemove(this, DefinitionsPackage.MACHINE__ASM_RULE_DEFINITIONS, Machine.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.RULE__BODY: |
| return getBody(); |
| case DefinitionsPackage.RULE__SYM_PARAMETERS: |
| return getSymParameters(); |
| case DefinitionsPackage.RULE__LOCAL_VARIABLES: |
| return getLocalVariables(); |
| case DefinitionsPackage.RULE__NAMESPACE: |
| return getNamespace(); |
| } |
| 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.RULE__BODY: |
| setBody((ASMRuleInvocation)newValue); |
| return; |
| case DefinitionsPackage.RULE__SYM_PARAMETERS: |
| getSymParameters().clear(); |
| getSymParameters().addAll((Collection<? extends SymbolicRuleParameter>)newValue); |
| return; |
| case DefinitionsPackage.RULE__LOCAL_VARIABLES: |
| getLocalVariables().clear(); |
| getLocalVariables().addAll((Collection<? extends Variable>)newValue); |
| return; |
| case DefinitionsPackage.RULE__NAMESPACE: |
| setNamespace((Machine)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case DefinitionsPackage.RULE__BODY: |
| setBody((ASMRuleInvocation)null); |
| return; |
| case DefinitionsPackage.RULE__SYM_PARAMETERS: |
| getSymParameters().clear(); |
| return; |
| case DefinitionsPackage.RULE__LOCAL_VARIABLES: |
| getLocalVariables().clear(); |
| return; |
| case DefinitionsPackage.RULE__NAMESPACE: |
| setNamespace((Machine)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case DefinitionsPackage.RULE__BODY: |
| return body != null; |
| case DefinitionsPackage.RULE__SYM_PARAMETERS: |
| return symParameters != null && !symParameters.isEmpty(); |
| case DefinitionsPackage.RULE__LOCAL_VARIABLES: |
| return localVariables != null && !localVariables.isEmpty(); |
| case DefinitionsPackage.RULE__NAMESPACE: |
| return getNamespace() != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| } //RuleImpl |