/**
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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.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.util.EcoreUtil;
import org.dresdenocl.pivotmodel.Enumeration;
import org.dresdenocl.pivotmodel.EnumerationLiteral;
import org.dresdenocl.pivotmodel.NamedElement;
import org.dresdenocl.pivotmodel.PivotModelFactory;
import org.dresdenocl.pivotmodel.PivotModelPackage;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Enumeration Literal</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.dresdenocl.pivotmodel.impl.EnumerationLiteralImpl#getEnumeration <em>Enumeration</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class EnumerationLiteralImpl extends NamedElementImpl implements
EnumerationLiteral {
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected EnumerationLiteralImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return PivotModelPackage.Literals.ENUMERATION_LITERAL;
}
/**
* Overridden to return the {@link #getEnumeration() enumeration} that belongs
* to this <code>EnumerationLiteral</code>.
*
* @see org.dresdenocl.pivotmodel.impl.NamedElementImpl#getOwner()
*/
@Override
public NamedElement getOwner() {
return getEnumeration();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Enumeration getEnumeration() {
if (eContainerFeatureID() != PivotModelPackage.ENUMERATION_LITERAL__ENUMERATION)
return null;
return (Enumeration) eInternalContainer();
}
/*
* (non-Javadoc)
* @see org.dresdenocl.pivotmodel.impl.NamedElementImpl#clone()
*/
@Override
public EnumerationLiteral clone() {
return (EnumerationLiteral) initialize(PivotModelFactory.eINSTANCE
.createEnumerationLiteral());
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetEnumeration(Enumeration newEnumeration,
NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newEnumeration,
PivotModelPackage.ENUMERATION_LITERAL__ENUMERATION, msgs);
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void setEnumeration(Enumeration newEnumeration) {
if (newEnumeration != eInternalContainer()
|| (eContainerFeatureID() != PivotModelPackage.ENUMERATION_LITERAL__ENUMERATION && newEnumeration != null)) {
if (EcoreUtil.isAncestor(this, newEnumeration))
throw new IllegalArgumentException(
"Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newEnumeration != null)
msgs = ((InternalEObject) newEnumeration).eInverseAdd(this,
PivotModelPackage.ENUMERATION__OWNED_LITERAL,
Enumeration.class, msgs);
msgs = basicSetEnumeration(newEnumeration, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
PivotModelPackage.ENUMERATION_LITERAL__ENUMERATION,
newEnumeration, newEnumeration));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case PivotModelPackage.ENUMERATION_LITERAL__ENUMERATION:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetEnumeration((Enumeration) 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.ENUMERATION_LITERAL__ENUMERATION:
return basicSetEnumeration(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.ENUMERATION_LITERAL__ENUMERATION:
return eInternalContainer().eInverseRemove(this,
PivotModelPackage.ENUMERATION__OWNED_LITERAL,
Enumeration.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.ENUMERATION_LITERAL__ENUMERATION:
return getEnumeration();
}
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.ENUMERATION_LITERAL__ENUMERATION:
setEnumeration((Enumeration) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case PivotModelPackage.ENUMERATION_LITERAL__ENUMERATION:
setEnumeration((Enumeration) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case PivotModelPackage.ENUMERATION_LITERAL__ENUMERATION:
return getEnumeration() != null;
}
return super.eIsSet(featureID);
}
} // EnumerationLiteralImpl