blob: 7db4eda325571bb0f51b6ee5dccdd8bd3cba5eeb [file] [log] [blame]
/**
* <copyright>
* Copyright (c) 2008, 2018 Open Canarias S.L. 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:
* A. Sanchez-Barbudo - initial API and implementation
* </copyright>
*
* $Id: AssertExpImpl.java,v 1.4 2009/05/15 16:13:08 radvorak Exp $
*/
package org.eclipse.m2m.qvt.oml.ecore.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.m2m.qvt.oml.ecore.ImperativeOCL.AssertExp;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.ImperativeOCLPackage;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.LogExp;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.SeverityKind;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.util.ImperativeOCLVisitor;
import org.eclipse.ocl.ecore.OCLExpression;
import org.eclipse.ocl.utilities.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Assert Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.AssertExpImpl#getAssertion <em>Assertion</em>}</li>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.AssertExpImpl#getLog <em>Log</em>}</li>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.AssertExpImpl#getSeverity <em>Severity</em>}</li>
* </ul>
* </p>
*
* @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);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (severity: "); //$NON-NLS-1$
result.append(severity);
result.append(')');
return result.toString();
}
/**
* @generated NOT
*/
@SuppressWarnings("unchecked")
@Override
public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) {
if (v instanceof ImperativeOCLVisitor)
return (T) ((ImperativeOCLVisitor) v).visitAssertExp(this);
return super.<T, U>accept(v);
}
} //AssertExpImpl