/**
* <copyright>
* Copyright (c) 2013 Willink Transformations, University 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:
* E.D.Willink - Initial API and implementation
* Adolfo Sanchez-Barbudo (University of York) - Bug397429
* </copyright>
*/
package org.eclipse.qvto.examples.pivot.imperativeocl.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.ocl.pivot.OCLExpression;
import org.eclipse.ocl.pivot.util.Visitor;
import org.eclipse.qvto.examples.pivot.imperativeocl.AssertExp;
import org.eclipse.qvto.examples.pivot.imperativeocl.ImperativeOCLPackage;
import org.eclipse.qvto.examples.pivot.imperativeocl.LogExp;
import org.eclipse.qvto.examples.pivot.imperativeocl.SeverityKind;
import org.eclipse.qvto.examples.pivot.imperativeocl.util.ImperativeOCLVisitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Assert Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.AssertExpImpl#getAssertion <em>Assertion</em>}</li>
* <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.AssertExpImpl#getLog <em>Log</em>}</li>
* <li>{@link org.eclipse.qvto.examples.pivot.imperativeocl.impl.AssertExpImpl#getSeverity <em>Severity</em>}</li>
* </ul>
*
* @generated
*/
public class AssertExpImpl extends ImperativeExpressionImpl implements AssertExp {
/**
* The cached value of the '{@link #getAssertion() <em>Assertion</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAssertion()
* @generated
* @ordered
*/
protected OCLExpression assertion;
/**
* The cached value of the '{@link #getLog() <em>Log</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLog()
* @generated
* @ordered
*/
protected LogExp log;
/**
* The default value of the '{@link #getSeverity() <em>Severity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSeverity()
* @generated
* @ordered
*/
protected static final SeverityKind SEVERITY_EDEFAULT = SeverityKind.ERROR;
/**
* The cached value of the '{@link #getSeverity() <em>Severity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSeverity()
* @generated
* @ordered
*/
protected SeverityKind severity = SEVERITY_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AssertExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ImperativeOCLPackage.Literals.ASSERT_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OCLExpression getAssertion() {
return assertion;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetAssertion(OCLExpression newAssertion, NotificationChain msgs) {
OCLExpression oldAssertion = assertion;
assertion = newAssertion;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSERT_EXP__ASSERTION, oldAssertion, newAssertion);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAssertion(OCLExpression newAssertion) {
if (newAssertion != assertion) {
NotificationChain msgs = null;
if (assertion != null)
msgs = ((InternalEObject)assertion).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSERT_EXP__ASSERTION, null, msgs);
if (newAssertion != null)
msgs = ((InternalEObject)newAssertion).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSERT_EXP__ASSERTION, null, msgs);
msgs = basicSetAssertion(newAssertion, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSERT_EXP__ASSERTION, newAssertion, newAssertion));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LogExp getLog() {
return log;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetLog(LogExp newLog, NotificationChain msgs) {
LogExp oldLog = log;
log = newLog;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSERT_EXP__LOG, oldLog, newLog);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setLog(LogExp newLog) {
if (newLog != log) {
NotificationChain msgs = null;
if (log != null)
msgs = ((InternalEObject)log).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSERT_EXP__LOG, null, msgs);
if (newLog != null)
msgs = ((InternalEObject)newLog).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.ASSERT_EXP__LOG, null, msgs);
msgs = basicSetLog(newLog, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSERT_EXP__LOG, newLog, newLog));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SeverityKind getSeverity() {
return severity;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSeverity(SeverityKind newSeverity) {
SeverityKind oldSeverity = severity;
severity = newSeverity == null ? SEVERITY_EDEFAULT : newSeverity;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.ASSERT_EXP__SEVERITY, oldSeverity, severity));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ImperativeOCLPackage.ASSERT_EXP__ASSERTION:
return basicSetAssertion(null, msgs);
case ImperativeOCLPackage.ASSERT_EXP__LOG:
return basicSetLog(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 ImperativeOCLPackage.ASSERT_EXP__ASSERTION:
return getAssertion();
case ImperativeOCLPackage.ASSERT_EXP__LOG:
return getLog();
case ImperativeOCLPackage.ASSERT_EXP__SEVERITY:
return getSeverity();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ImperativeOCLPackage.ASSERT_EXP__ASSERTION:
setAssertion((OCLExpression)newValue);
return;
case ImperativeOCLPackage.ASSERT_EXP__LOG:
setLog((LogExp)newValue);
return;
case ImperativeOCLPackage.ASSERT_EXP__SEVERITY:
setSeverity((SeverityKind)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ImperativeOCLPackage.ASSERT_EXP__ASSERTION:
setAssertion((OCLExpression)null);
return;
case ImperativeOCLPackage.ASSERT_EXP__LOG:
setLog((LogExp)null);
return;
case ImperativeOCLPackage.ASSERT_EXP__SEVERITY:
setSeverity(SEVERITY_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ImperativeOCLPackage.ASSERT_EXP__ASSERTION:
return assertion != null;
case ImperativeOCLPackage.ASSERT_EXP__LOG:
return log != null;
case ImperativeOCLPackage.ASSERT_EXP__SEVERITY:
return severity != SEVERITY_EDEFAULT;
}
return super.eIsSet(featureID);
}
@Override
public String toString() {
return super.toString();
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(Visitor<R> visitor) {
return (R) ((ImperativeOCLVisitor<?>)visitor).visitAssertExp(this);
}
} //AssertExpImpl