| /** |
| * Copyright (c) 2016 Willink Transformations, Univesity of York 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: |
| * Adolfo Sanchez-Barbudo Herrera - initial API and implementation |
| */ |
| package astm.impl; |
| |
| import astm.AstmPackage; |
| import astm.LabelDefinition; |
| import astm.LabeledStatement; |
| import astm.Statement; |
| |
| import astm.util.Visitor; |
| |
| 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.jdt.annotation.NonNull; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Labeled Statement</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link astm.impl.LabeledStatementImpl#getLabel <em>Label</em>}</li> |
| * <li>{@link astm.impl.LabeledStatementImpl#getStatement <em>Statement</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class LabeledStatementImpl extends StatementImpl implements LabeledStatement { |
| /** |
| * The cached value of the '{@link #getLabel() <em>Label</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLabel() |
| * @generated |
| * @ordered |
| */ |
| protected LabelDefinition label; |
| |
| /** |
| * The cached value of the '{@link #getStatement() <em>Statement</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getStatement() |
| * @generated |
| * @ordered |
| */ |
| protected Statement statement; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected LabeledStatementImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AstmPackage.Literals.LABELED_STATEMENT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public LabelDefinition getLabel() { |
| return label; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetLabel(LabelDefinition newLabel, NotificationChain msgs) { |
| LabelDefinition oldLabel = label; |
| label = newLabel; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AstmPackage.LABELED_STATEMENT__LABEL, oldLabel, newLabel); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setLabel(LabelDefinition newLabel) { |
| if (newLabel != label) { |
| NotificationChain msgs = null; |
| if (label != null) |
| msgs = ((InternalEObject)label).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AstmPackage.LABELED_STATEMENT__LABEL, null, msgs); |
| if (newLabel != null) |
| msgs = ((InternalEObject)newLabel).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AstmPackage.LABELED_STATEMENT__LABEL, null, msgs); |
| msgs = basicSetLabel(newLabel, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AstmPackage.LABELED_STATEMENT__LABEL, newLabel, newLabel)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Statement getStatement() { |
| return statement; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetStatement(Statement newStatement, NotificationChain msgs) { |
| Statement oldStatement = statement; |
| statement = newStatement; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AstmPackage.LABELED_STATEMENT__STATEMENT, oldStatement, newStatement); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setStatement(Statement newStatement) { |
| if (newStatement != statement) { |
| NotificationChain msgs = null; |
| if (statement != null) |
| msgs = ((InternalEObject)statement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AstmPackage.LABELED_STATEMENT__STATEMENT, null, msgs); |
| if (newStatement != null) |
| msgs = ((InternalEObject)newStatement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AstmPackage.LABELED_STATEMENT__STATEMENT, null, msgs); |
| msgs = basicSetStatement(newStatement, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AstmPackage.LABELED_STATEMENT__STATEMENT, newStatement, newStatement)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case AstmPackage.LABELED_STATEMENT__LABEL: |
| return basicSetLabel(null, msgs); |
| case AstmPackage.LABELED_STATEMENT__STATEMENT: |
| return basicSetStatement(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 AstmPackage.LABELED_STATEMENT__LABEL: |
| return getLabel(); |
| case AstmPackage.LABELED_STATEMENT__STATEMENT: |
| return getStatement(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case AstmPackage.LABELED_STATEMENT__LABEL: |
| setLabel((LabelDefinition)newValue); |
| return; |
| case AstmPackage.LABELED_STATEMENT__STATEMENT: |
| setStatement((Statement)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AstmPackage.LABELED_STATEMENT__LABEL: |
| setLabel((LabelDefinition)null); |
| return; |
| case AstmPackage.LABELED_STATEMENT__STATEMENT: |
| setStatement((Statement)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AstmPackage.LABELED_STATEMENT__LABEL: |
| return label != null; |
| case AstmPackage.LABELED_STATEMENT__STATEMENT: |
| return statement != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitLabeledStatement(this); |
| } |
| |
| } //LabeledStatementImpl |