/** | |
* ******************************************************************************* | |
* 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 java.util.Collection; | |
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.EObjectContainmentEList; | |
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
import org.eclipse.gmt.modisco.java.AbstractVariablesContainer; | |
import org.eclipse.gmt.modisco.java.Annotation; | |
import org.eclipse.gmt.modisco.java.Modifier; | |
import org.eclipse.gmt.modisco.java.TypeAccess; | |
import org.eclipse.gmt.modisco.java.VariableDeclarationFragment; | |
import org.eclipse.gmt.modisco.java.VariableDeclarationStatement; | |
import org.eclipse.gmt.modisco.java.emf.JavaPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Variable Declaration Statement</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.VariableDeclarationStatementImpl#getType <em>Type</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.VariableDeclarationStatementImpl#getFragments <em>Fragments</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.VariableDeclarationStatementImpl#getExtraArrayDimensions <em>Extra Array Dimensions</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.VariableDeclarationStatementImpl#getModifier <em>Modifier</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.VariableDeclarationStatementImpl#getAnnotations <em>Annotations</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class VariableDeclarationStatementImpl extends StatementImpl implements VariableDeclarationStatement { | |
/** | |
* The cached value of the '{@link #getType() <em>Type</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getType() | |
* @generated | |
* @ordered | |
*/ | |
protected TypeAccess type; | |
/** | |
* The cached value of the '{@link #getFragments() <em>Fragments</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getFragments() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<VariableDeclarationFragment> fragments; | |
/** | |
* The default value of the '{@link #getExtraArrayDimensions() <em>Extra Array Dimensions</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getExtraArrayDimensions() | |
* @generated | |
* @ordered | |
*/ | |
protected static final int EXTRA_ARRAY_DIMENSIONS_EDEFAULT = 0; | |
/** | |
* The cached value of the '{@link #getExtraArrayDimensions() <em>Extra Array Dimensions</em>}' attribute. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getExtraArrayDimensions() | |
* @generated | |
* @ordered | |
*/ | |
protected int extraArrayDimensions = EXTRA_ARRAY_DIMENSIONS_EDEFAULT; | |
/** | |
* The cached value of the '{@link #getModifier() <em>Modifier</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getModifier() | |
* @generated | |
* @ordered | |
*/ | |
protected Modifier modifier; | |
/** | |
* The cached value of the '{@link #getAnnotations() <em>Annotations</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getAnnotations() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Annotation> annotations; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected VariableDeclarationStatementImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return JavaPackage.eINSTANCE.getVariableDeclarationStatement(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public TypeAccess getType() { | |
return type; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetType(TypeAccess newType, NotificationChain msgs) { | |
TypeAccess oldType = type; | |
type = newType; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE, oldType, newType); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setType(TypeAccess newType) { | |
if (newType != type) { | |
NotificationChain msgs = null; | |
if (type != null) | |
msgs = ((InternalEObject)type).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE, null, msgs); | |
if (newType != null) | |
msgs = ((InternalEObject)newType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE, null, msgs); | |
msgs = basicSetType(newType, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE, newType, newType)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<VariableDeclarationFragment> getFragments() { | |
if (fragments == null) { | |
fragments = new EObjectContainmentWithInverseEList<VariableDeclarationFragment>(VariableDeclarationFragment.class, this, JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS, JavaPackage.VARIABLE_DECLARATION_FRAGMENT__VARIABLES_CONTAINER); | |
} | |
return fragments; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public int getExtraArrayDimensions() { | |
return extraArrayDimensions; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setExtraArrayDimensions(int newExtraArrayDimensions) { | |
int oldExtraArrayDimensions = extraArrayDimensions; | |
extraArrayDimensions = newExtraArrayDimensions; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION_STATEMENT__EXTRA_ARRAY_DIMENSIONS, oldExtraArrayDimensions, extraArrayDimensions)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Modifier getModifier() { | |
return modifier; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetModifier(Modifier newModifier, NotificationChain msgs) { | |
Modifier oldModifier = modifier; | |
modifier = newModifier; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER, oldModifier, newModifier); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setModifier(Modifier newModifier) { | |
if (newModifier != modifier) { | |
NotificationChain msgs = null; | |
if (modifier != null) | |
msgs = ((InternalEObject)modifier).eInverseRemove(this, JavaPackage.MODIFIER__VARIABLE_DECLARATION_STATEMENT, Modifier.class, msgs); | |
if (newModifier != null) | |
msgs = ((InternalEObject)newModifier).eInverseAdd(this, JavaPackage.MODIFIER__VARIABLE_DECLARATION_STATEMENT, Modifier.class, msgs); | |
msgs = basicSetModifier(newModifier, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER, newModifier, newModifier)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<Annotation> getAnnotations() { | |
if (annotations == null) { | |
annotations = new EObjectContainmentEList<Annotation>(Annotation.class, this, JavaPackage.VARIABLE_DECLARATION_STATEMENT__ANNOTATIONS); | |
} | |
return annotations; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS: | |
return ((InternalEList<InternalEObject>)(InternalEList<?>)getFragments()).basicAdd(otherEnd, msgs); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER: | |
if (modifier != null) | |
msgs = ((InternalEObject)modifier).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER, null, msgs); | |
return basicSetModifier((Modifier)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_STATEMENT__TYPE: | |
return basicSetType(null, msgs); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS: | |
return ((InternalEList<?>)getFragments()).basicRemove(otherEnd, msgs); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER: | |
return basicSetModifier(null, msgs); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__ANNOTATIONS: | |
return ((InternalEList<?>)getAnnotations()).basicRemove(otherEnd, 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.VARIABLE_DECLARATION_STATEMENT__TYPE: | |
return getType(); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS: | |
return getFragments(); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__EXTRA_ARRAY_DIMENSIONS: | |
return getExtraArrayDimensions(); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER: | |
return getModifier(); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__ANNOTATIONS: | |
return getAnnotations(); | |
} | |
return super.eGet(featureID, resolve, coreType); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public void eSet(int featureID, Object newValue) { | |
switch (featureID) { | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE: | |
setType((TypeAccess)newValue); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS: | |
getFragments().clear(); | |
getFragments().addAll((Collection<? extends VariableDeclarationFragment>)newValue); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__EXTRA_ARRAY_DIMENSIONS: | |
setExtraArrayDimensions((Integer)newValue); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER: | |
setModifier((Modifier)newValue); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__ANNOTATIONS: | |
getAnnotations().clear(); | |
getAnnotations().addAll((Collection<? extends Annotation>)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_STATEMENT__TYPE: | |
setType((TypeAccess)null); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS: | |
getFragments().clear(); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__EXTRA_ARRAY_DIMENSIONS: | |
setExtraArrayDimensions(EXTRA_ARRAY_DIMENSIONS_EDEFAULT); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER: | |
setModifier((Modifier)null); | |
return; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__ANNOTATIONS: | |
getAnnotations().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE: | |
return type != null; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS: | |
return fragments != null && !fragments.isEmpty(); | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__EXTRA_ARRAY_DIMENSIONS: | |
return extraArrayDimensions != EXTRA_ARRAY_DIMENSIONS_EDEFAULT; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__MODIFIER: | |
return modifier != null; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__ANNOTATIONS: | |
return annotations != null && !annotations.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { | |
if (baseClass == AbstractVariablesContainer.class) { | |
switch (derivedFeatureID) { | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE: return JavaPackage.ABSTRACT_VARIABLES_CONTAINER__TYPE; | |
case JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS: return JavaPackage.ABSTRACT_VARIABLES_CONTAINER__FRAGMENTS; | |
default: return -1; | |
} | |
} | |
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { | |
if (baseClass == AbstractVariablesContainer.class) { | |
switch (baseFeatureID) { | |
case JavaPackage.ABSTRACT_VARIABLES_CONTAINER__TYPE: return JavaPackage.VARIABLE_DECLARATION_STATEMENT__TYPE; | |
case JavaPackage.ABSTRACT_VARIABLES_CONTAINER__FRAGMENTS: return JavaPackage.VARIABLE_DECLARATION_STATEMENT__FRAGMENTS; | |
default: return -1; | |
} | |
} | |
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public String toString() { | |
if (eIsProxy()) return super.toString(); | |
StringBuffer result = new StringBuffer(super.toString()); | |
result.append(" (extraArrayDimensions: "); | |
result.append(extraArrayDimensions); | |
result.append(')'); | |
return result.toString(); | |
} | |
} //VariableDeclarationStatementImpl |