/** | |
* ******************************************************************************* | |
* Copyright (c) 2009 Mia-Software and others. | |
* 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: | |
* | |
* 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.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.EObjectWithInverseResolvingEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
import org.eclipse.modisco.java.AnonymousClassDeclaration; | |
import org.eclipse.modisco.java.EnumConstantDeclaration; | |
import org.eclipse.modisco.java.Expression; | |
import org.eclipse.modisco.java.SingleVariableAccess; | |
import org.eclipse.modisco.java.VariableDeclaration; | |
import org.eclipse.modisco.java.emf.JavaPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Enum Constant Declaration</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.EnumConstantDeclarationImpl#getExtraArrayDimensions <em>Extra Array Dimensions</em>}</li> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.EnumConstantDeclarationImpl#getInitializer <em>Initializer</em>}</li> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.EnumConstantDeclarationImpl#getUsageInVariableAccess <em>Usage In Variable Access</em>}</li> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.EnumConstantDeclarationImpl#getAnonymousClassDeclaration <em>Anonymous Class Declaration</em>}</li> | |
* <li>{@link org.eclipse.modisco.java.emf.impl.EnumConstantDeclarationImpl#getArguments <em>Arguments</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class EnumConstantDeclarationImpl extends BodyDeclarationImpl implements EnumConstantDeclaration { | |
/** | |
* 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 #getInitializer() <em>Initializer</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getInitializer() | |
* @generated | |
* @ordered | |
*/ | |
protected Expression initializer; | |
/** | |
* The cached value of the '{@link #getUsageInVariableAccess() <em>Usage In Variable Access</em>}' reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getUsageInVariableAccess() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<SingleVariableAccess> usageInVariableAccess; | |
/** | |
* The cached value of the '{@link #getAnonymousClassDeclaration() <em>Anonymous Class Declaration</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getAnonymousClassDeclaration() | |
* @generated | |
* @ordered | |
*/ | |
protected AnonymousClassDeclaration anonymousClassDeclaration; | |
/** | |
* The cached value of the '{@link #getArguments() <em>Arguments</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getArguments() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Expression> arguments; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected EnumConstantDeclarationImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return JavaPackage.eINSTANCE.getEnumConstantDeclaration(); | |
} | |
/** | |
* <!-- 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.ENUM_CONSTANT_DECLARATION__EXTRA_ARRAY_DIMENSIONS, oldExtraArrayDimensions, extraArrayDimensions)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Expression getInitializer() { | |
return initializer; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetInitializer(Expression newInitializer, NotificationChain msgs) { | |
Expression oldInitializer = initializer; | |
initializer = newInitializer; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER, oldInitializer, newInitializer); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setInitializer(Expression newInitializer) { | |
if (newInitializer != initializer) { | |
NotificationChain msgs = null; | |
if (initializer != null) | |
msgs = ((InternalEObject)initializer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER, null, msgs); | |
if (newInitializer != null) | |
msgs = ((InternalEObject)newInitializer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER, null, msgs); | |
msgs = basicSetInitializer(newInitializer, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER, newInitializer, newInitializer)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<SingleVariableAccess> getUsageInVariableAccess() { | |
if (usageInVariableAccess == null) { | |
usageInVariableAccess = new EObjectWithInverseResolvingEList<SingleVariableAccess>(SingleVariableAccess.class, this, JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS, JavaPackage.SINGLE_VARIABLE_ACCESS__VARIABLE); | |
} | |
return usageInVariableAccess; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public AnonymousClassDeclaration getAnonymousClassDeclaration() { | |
return anonymousClassDeclaration; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetAnonymousClassDeclaration(AnonymousClassDeclaration newAnonymousClassDeclaration, NotificationChain msgs) { | |
AnonymousClassDeclaration oldAnonymousClassDeclaration = anonymousClassDeclaration; | |
anonymousClassDeclaration = newAnonymousClassDeclaration; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION, oldAnonymousClassDeclaration, newAnonymousClassDeclaration); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setAnonymousClassDeclaration(AnonymousClassDeclaration newAnonymousClassDeclaration) { | |
if (newAnonymousClassDeclaration != anonymousClassDeclaration) { | |
NotificationChain msgs = null; | |
if (anonymousClassDeclaration != null) | |
msgs = ((InternalEObject)anonymousClassDeclaration).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION, null, msgs); | |
if (newAnonymousClassDeclaration != null) | |
msgs = ((InternalEObject)newAnonymousClassDeclaration).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION, null, msgs); | |
msgs = basicSetAnonymousClassDeclaration(newAnonymousClassDeclaration, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION, newAnonymousClassDeclaration, newAnonymousClassDeclaration)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<Expression> getArguments() { | |
if (arguments == null) { | |
arguments = new EObjectContainmentEList<Expression>(Expression.class, this, JavaPackage.ENUM_CONSTANT_DECLARATION__ARGUMENTS); | |
} | |
return arguments; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS: | |
return ((InternalEList<InternalEObject>)(InternalEList<?>)getUsageInVariableAccess()).basicAdd(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.ENUM_CONSTANT_DECLARATION__INITIALIZER: | |
return basicSetInitializer(null, msgs); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS: | |
return ((InternalEList<?>)getUsageInVariableAccess()).basicRemove(otherEnd, msgs); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION: | |
return basicSetAnonymousClassDeclaration(null, msgs); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ARGUMENTS: | |
return ((InternalEList<?>)getArguments()).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.ENUM_CONSTANT_DECLARATION__EXTRA_ARRAY_DIMENSIONS: | |
return getExtraArrayDimensions(); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER: | |
return getInitializer(); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS: | |
return getUsageInVariableAccess(); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION: | |
return getAnonymousClassDeclaration(); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ARGUMENTS: | |
return getArguments(); | |
} | |
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.ENUM_CONSTANT_DECLARATION__EXTRA_ARRAY_DIMENSIONS: | |
setExtraArrayDimensions((Integer)newValue); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER: | |
setInitializer((Expression)newValue); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS: | |
getUsageInVariableAccess().clear(); | |
getUsageInVariableAccess().addAll((Collection<? extends SingleVariableAccess>)newValue); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION: | |
setAnonymousClassDeclaration((AnonymousClassDeclaration)newValue); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ARGUMENTS: | |
getArguments().clear(); | |
getArguments().addAll((Collection<? extends Expression>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__EXTRA_ARRAY_DIMENSIONS: | |
setExtraArrayDimensions(EXTRA_ARRAY_DIMENSIONS_EDEFAULT); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER: | |
setInitializer((Expression)null); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS: | |
getUsageInVariableAccess().clear(); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION: | |
setAnonymousClassDeclaration((AnonymousClassDeclaration)null); | |
return; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ARGUMENTS: | |
getArguments().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__EXTRA_ARRAY_DIMENSIONS: | |
return extraArrayDimensions != EXTRA_ARRAY_DIMENSIONS_EDEFAULT; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER: | |
return initializer != null; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS: | |
return usageInVariableAccess != null && !usageInVariableAccess.isEmpty(); | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ANONYMOUS_CLASS_DECLARATION: | |
return anonymousClassDeclaration != null; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__ARGUMENTS: | |
return arguments != null && !arguments.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { | |
if (baseClass == VariableDeclaration.class) { | |
switch (derivedFeatureID) { | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__EXTRA_ARRAY_DIMENSIONS: return JavaPackage.VARIABLE_DECLARATION__EXTRA_ARRAY_DIMENSIONS; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER: return JavaPackage.VARIABLE_DECLARATION__INITIALIZER; | |
case JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS: return JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS; | |
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 == VariableDeclaration.class) { | |
switch (baseFeatureID) { | |
case JavaPackage.VARIABLE_DECLARATION__EXTRA_ARRAY_DIMENSIONS: return JavaPackage.ENUM_CONSTANT_DECLARATION__EXTRA_ARRAY_DIMENSIONS; | |
case JavaPackage.VARIABLE_DECLARATION__INITIALIZER: return JavaPackage.ENUM_CONSTANT_DECLARATION__INITIALIZER; | |
case JavaPackage.VARIABLE_DECLARATION__USAGE_IN_VARIABLE_ACCESS: return JavaPackage.ENUM_CONSTANT_DECLARATION__USAGE_IN_VARIABLE_ACCESS; | |
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(); | |
} | |
} //EnumConstantDeclarationImpl |