/** | |
* ******************************************************************************* | |
* 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 v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* | |
* Sebastien Minguet (Mia-Software) - initial API and implementation | |
* Frederic Madiot (Mia-Software) - initial API and implementation | |
* Fabien Giquel (Mia-Software) - initial API and implementation | |
* Gabriel Barbier (Mia-Software) - initial API and implementation | |
* Erwan Breton (Sodifrance) - initial API and implementation | |
* Romain Dervaux (Mia-Software) - initial API and implementation | |
* ******************************************************************************* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.gmt.modisco.java.emf.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.gmt.modisco.java.Expression; | |
import org.eclipse.gmt.modisco.java.SingleVariableAccess; | |
import org.eclipse.gmt.modisco.java.VariableDeclaration; | |
import org.eclipse.gmt.modisco.java.emf.JavaPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Single Variable Access</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.SingleVariableAccessImpl#getVariable <em>Variable</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.SingleVariableAccessImpl#getQualifier <em>Qualifier</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class SingleVariableAccessImpl extends ExpressionImpl implements SingleVariableAccess { | |
/** | |
* The cached value of the '{@link #getVariable() <em>Variable</em>}' reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getVariable() | |
* @generated | |
* @ordered | |
*/ | |
protected VariableDeclaration variable; | |
/** | |
* The cached value of the '{@link #getQualifier() <em>Qualifier</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getQualifier() | |
* @generated | |
* @ordered | |
*/ | |
protected Expression qualifier; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected SingleVariableAccessImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return JavaPackage.eINSTANCE.getSingleVariableAccess(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public VariableDeclaration getVariable() { | |
if (variable != null && variable.eIsProxy()) { | |
InternalEObject oldVariable = (InternalEObject)variable; | |
variable = (VariableDeclaration)eResolveProxy(oldVariable); | |
if (variable != oldVariable) { | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.RESOLVE, JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE, oldVariable, variable)); | |
} | |
} | |
return variable; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public VariableDeclaration basicGetVariable() { | |
return variable; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetVariable(VariableDeclaration newVariable, NotificationChain msgs) { | |
VariableDeclaration oldVariable = variable; | |
variable = newVariable; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE, oldVariable, newVariable); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setVariable(VariableDeclaration newVariable) { | |
if (newVariable != variable) { | |
NotificationChain msgs = null; | |
if (variable != null) | |
msgs = ((InternalEObject)variable).eInverseRemove(this, JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS, VariableDeclaration.class, msgs); | |
if (newVariable != null) | |
msgs = ((InternalEObject)newVariable).eInverseAdd(this, JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS, VariableDeclaration.class, msgs); | |
msgs = basicSetVariable(newVariable, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE, newVariable, newVariable)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Expression getQualifier() { | |
return qualifier; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetQualifier(Expression newQualifier, NotificationChain msgs) { | |
Expression oldQualifier = qualifier; | |
qualifier = newQualifier; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER, oldQualifier, newQualifier); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setQualifier(Expression newQualifier) { | |
if (newQualifier != qualifier) { | |
NotificationChain msgs = null; | |
if (qualifier != null) | |
msgs = ((InternalEObject)qualifier).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER, null, msgs); | |
if (newQualifier != null) | |
msgs = ((InternalEObject)newQualifier).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER, null, msgs); | |
msgs = basicSetQualifier(newQualifier, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER, newQualifier, newQualifier)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE: | |
if (variable != null) | |
msgs = ((InternalEObject)variable).eInverseRemove(this, JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS, VariableDeclaration.class, msgs); | |
return basicSetVariable((VariableDeclaration)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.SINGLE_VARIABLE_ACCESS__VARIABLE: | |
return basicSetVariable(null, msgs); | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER: | |
return basicSetQualifier(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 JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE: | |
if (resolve) return getVariable(); | |
return basicGetVariable(); | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER: | |
return getQualifier(); | |
} | |
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.SINGLE_VARIABLE_ACCESS__VARIABLE: | |
setVariable((VariableDeclaration)newValue); | |
return; | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER: | |
setQualifier((Expression)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE: | |
setVariable((VariableDeclaration)null); | |
return; | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER: | |
setQualifier((Expression)null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE: | |
return variable != null; | |
case JavaPackage.SINGLE_VARIABLE_ACCESS__QUALIFIER: | |
return qualifier != null; | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* Improve the basic toString method for debugging purpose. | |
*/ | |
@Override | |
public String toString() { | |
String result = super.toString(); | |
result = result.concat("\n").concat("variable declaration = " + this.variable); //$NON-NLS-1$ //$NON-NLS-2$ | |
return result; | |
} | |
} //SingleVariableAccessImpl |