/**
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright (C) 2007 Matthias Braeuer (braeuer.matthias@web.de). *
* All rights reserved. *
* *
* This work was done as a project at the Chair for Software Technology, *
* Dresden University Of Technology, Germany (http://st.inf.tu-dresden.de). *
* It is understood that any modification not identified as such is not *
* covered by the preceding statement. *
* *
* This work is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Library General Public License as published *
* by the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This work is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public *
* License for more details. *
* *
* You should have received a copy of the GNU Library General Public License *
* along with this library; if not, you can view it online at *
* http://www.fsf.org/licensing/licenses/gpl.html. *
* *
* To submit a bug report, send a comment, or get the latest news on this *
* project, please visit the website: http://dresden-ocl.sourceforge.net. *
* For more information on OCL and related projects visit the OCL Portal: *
* http://st.inf.tu-dresden.de/ocl *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* $Id$
*/
package org.dresdenocl.pivotmodel.impl;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
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.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.dresdenocl.pivotmodel.Constraint;
import org.dresdenocl.pivotmodel.Expression;
import org.dresdenocl.pivotmodel.PivotModelPackage;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Expression</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.dresdenocl.pivotmodel.impl.ExpressionImpl#getBody <em>Body</em>}</li>
* <li>{@link org.dresdenocl.pivotmodel.impl.ExpressionImpl#getLanguage <em>Language</em>}</li>
* <li>{@link org.dresdenocl.pivotmodel.impl.ExpressionImpl#getConstraint <em>Constraint</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ExpressionImpl extends EObjectImpl implements Expression {
/**
* The default value of the '{@link #getBody() <em>Body</em>}' attribute. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getBody()
* @generated
* @ordered
*/
protected static final String BODY_EDEFAULT = null;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' attribute. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getBody()
* @generated
* @ordered
*/
protected String body = BODY_EDEFAULT;
/**
* The default value of the '{@link #getLanguage() <em>Language</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getLanguage()
* @generated
* @ordered
*/
protected static final String LANGUAGE_EDEFAULT = null;
/**
* The cached value of the '{@link #getLanguage() <em>Language</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getLanguage()
* @generated
* @ordered
*/
protected String language = LANGUAGE_EDEFAULT;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected ExpressionImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return PivotModelPackage.Literals.EXPRESSION;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public String getBody() {
return body;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void setBody(String newBody) {
String oldBody = body;
body = newBody;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
PivotModelPackage.EXPRESSION__BODY, oldBody, body));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public String getLanguage() {
return language;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void setLanguage(String newLanguage) {
String oldLanguage = language;
language = newLanguage;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
PivotModelPackage.EXPRESSION__LANGUAGE, oldLanguage, language));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Constraint getConstraint() {
if (eContainerFeatureID() != PivotModelPackage.EXPRESSION__CONSTRAINT)
return null;
return (Constraint) eContainer();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetConstraint(Constraint newConstraint,
NotificationChain msgs) {
msgs =
eBasicSetContainer((InternalEObject) newConstraint,
PivotModelPackage.EXPRESSION__CONSTRAINT, msgs);
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void setConstraint(Constraint newConstraint) {
if (newConstraint != eInternalContainer()
|| (eContainerFeatureID() != PivotModelPackage.EXPRESSION__CONSTRAINT && newConstraint != null)) {
if (EcoreUtil.isAncestor(this, newConstraint))
throw new IllegalArgumentException(
"Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newConstraint != null)
msgs =
((InternalEObject) newConstraint).eInverseAdd(this,
PivotModelPackage.CONSTRAINT__SPECIFICATION, Constraint.class,
msgs);
msgs = basicSetConstraint(newConstraint, msgs);
if (msgs != null)
msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
PivotModelPackage.EXPRESSION__CONSTRAINT, newConstraint,
newConstraint));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID,
NotificationChain msgs) {
switch (featureID) {
case PivotModelPackage.EXPRESSION__CONSTRAINT:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetConstraint((Constraint) 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 PivotModelPackage.EXPRESSION__CONSTRAINT:
return basicSetConstraint(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(
NotificationChain msgs) {
switch (eContainerFeatureID()) {
case PivotModelPackage.EXPRESSION__CONSTRAINT:
return eInternalContainer().eInverseRemove(this,
PivotModelPackage.CONSTRAINT__SPECIFICATION, Constraint.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 PivotModelPackage.EXPRESSION__BODY:
return getBody();
case PivotModelPackage.EXPRESSION__LANGUAGE:
return getLanguage();
case PivotModelPackage.EXPRESSION__CONSTRAINT:
return getConstraint();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case PivotModelPackage.EXPRESSION__BODY:
setBody((String) newValue);
return;
case PivotModelPackage.EXPRESSION__LANGUAGE:
setLanguage((String) newValue);
return;
case PivotModelPackage.EXPRESSION__CONSTRAINT:
setConstraint((Constraint) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case PivotModelPackage.EXPRESSION__BODY:
setBody(BODY_EDEFAULT);
return;
case PivotModelPackage.EXPRESSION__LANGUAGE:
setLanguage(LANGUAGE_EDEFAULT);
return;
case PivotModelPackage.EXPRESSION__CONSTRAINT:
setConstraint((Constraint) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case PivotModelPackage.EXPRESSION__BODY:
return BODY_EDEFAULT == null ? body != null : !BODY_EDEFAULT.equals(body);
case PivotModelPackage.EXPRESSION__LANGUAGE:
return LANGUAGE_EDEFAULT == null ? language != null : !LANGUAGE_EDEFAULT
.equals(language);
case PivotModelPackage.EXPRESSION__CONSTRAINT:
return getConstraint() != null;
}
return super.eIsSet(featureID);
}
/**
* Adapted the EMF implementation to use Jakarta Commons Lang instead.
*
* @see java.lang.Object#toString()
*
* @generated NOT
*/
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.appendSuper(super.toString())
.append("body", body).append("language", language).toString(); //$NON-NLS-1$ //$NON-NLS-2$
}
} // ExpressionImpl