/** | |
* ******************************************************************************* | |
* Copyright (c) 2009 Mia-Software. | |
* 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: | |
* | |
* Fabien Giquel (Mia-Software) - initial API and implementation | |
* Gregoire DUPE (Mia-Software) - initial API and implementation | |
* ******************************************************************************* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.modisco.java.nousages.impl; | |
import org.eclipse.emf.common.notify.Notification; | |
import org.eclipse.emf.common.notify.NotificationChain; | |
import org.eclipse.emf.common.util.EList; | |
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.eclipse.modisco.java.AbstractVariablesContainer; | |
import org.eclipse.modisco.java.ImportDeclaration; | |
import org.eclipse.modisco.java.SingleVariableAccess; | |
import org.eclipse.modisco.java.VariableDeclarationFragment; | |
import org.eclipse.modisco.java.nousages.meta.JavaPackage; | |
/** | |
* <!-- begin-user-doc --> An implementation of the model object ' | |
* <em><b>Variable Declaration Fragment</b></em>'. <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li> | |
* {@link org.eclipse.modisco.java.nousages.impl.VariableDeclarationFragmentImpl#getVariablesContainer | |
* <em>Variables Container</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class VariableDeclarationFragmentImpl extends VariableDeclarationImpl | |
implements VariableDeclarationFragment { | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
protected VariableDeclarationFragmentImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return JavaPackage.eINSTANCE.getVariableDeclarationFragment(); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
public AbstractVariablesContainer getVariablesContainer() { | |
if (eContainerFeatureID() != JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER) | |
return null; | |
return (AbstractVariablesContainer) eContainer(); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
public NotificationChain basicSetVariablesContainer( | |
AbstractVariablesContainer newVariablesContainer, | |
NotificationChain msgs) { | |
msgs = eBasicSetContainer((InternalEObject) newVariablesContainer, | |
JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER, | |
msgs); | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
public void setVariablesContainer( | |
AbstractVariablesContainer newVariablesContainer) { | |
if (newVariablesContainer != eInternalContainer() | |
|| (eContainerFeatureID() != JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER && newVariablesContainer != null)) { | |
if (EcoreUtil.isAncestor(this, newVariablesContainer)) | |
throw new IllegalArgumentException( | |
"Recursive containment not allowed for " + toString()); //$NON-NLS-1$ | |
NotificationChain msgs = null; | |
if (eInternalContainer() != null) | |
msgs = eBasicRemoveFromContainer(msgs); | |
if (newVariablesContainer != null) | |
msgs = ((InternalEObject) newVariablesContainer).eInverseAdd( | |
this, | |
JavaPackage.ABSTRACT_VARIABLES_CONTAINER__FRAGMENTS, | |
AbstractVariablesContainer.class, msgs); | |
msgs = basicSetVariablesContainer(newVariablesContainer, msgs); | |
if (msgs != null) | |
msgs.dispatch(); | |
} else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl( | |
this, | |
Notification.SET, | |
JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER, | |
newVariablesContainer, newVariablesContainer)); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, | |
int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER: | |
if (eInternalContainer() != null) | |
msgs = eBasicRemoveFromContainer(msgs); | |
return basicSetVariablesContainer( | |
(AbstractVariablesContainer) 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 JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER: | |
return basicSetVariablesContainer(null, msgs); | |
} | |
return super.eInverseRemove(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eBasicRemoveFromContainerFeature( | |
NotificationChain msgs) { | |
switch (eContainerFeatureID()) { | |
case JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER: | |
return eInternalContainer().eInverseRemove(this, | |
JavaPackage.ABSTRACT_VARIABLES_CONTAINER__FRAGMENTS, | |
AbstractVariablesContainer.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 JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER: | |
return getVariablesContainer(); | |
} | |
return super.eGet(featureID, resolve, coreType); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
@Override | |
public void eSet(int featureID, Object newValue) { | |
switch (featureID) { | |
case JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER: | |
setVariablesContainer((AbstractVariablesContainer) newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER: | |
setVariablesContainer((AbstractVariablesContainer) null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER: | |
return getVariablesContainer() != null; | |
} | |
return super.eIsSet(featureID); | |
} | |
public EList<SingleVariableAccess> getUsageInVariableAccess() { | |
// no usage references | |
return null; | |
} | |
public EList<ImportDeclaration> getUsagesInImports() { | |
// no usage references | |
return null; | |
} | |
} // VariableDeclarationFragmentImpl |