/** | |
* ******************************************************************************* | |
* 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.InternalEList; | |
import org.eclipse.gmt.modisco.java.ArrayCreation; | |
import org.eclipse.gmt.modisco.java.ArrayInitializer; | |
import org.eclipse.gmt.modisco.java.Expression; | |
import org.eclipse.gmt.modisco.java.TypeAccess; | |
import org.eclipse.gmt.modisco.java.emf.JavaPackage; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Array Creation</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.ArrayCreationImpl#getDimensions <em>Dimensions</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.ArrayCreationImpl#getInitializer <em>Initializer</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.java.emf.impl.ArrayCreationImpl#getType <em>Type</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class ArrayCreationImpl extends ExpressionImpl implements ArrayCreation { | |
/** | |
* The cached value of the '{@link #getDimensions() <em>Dimensions</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getDimensions() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<Expression> dimensions; | |
/** | |
* The cached value of the '{@link #getInitializer() <em>Initializer</em>}' containment reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getInitializer() | |
* @generated | |
* @ordered | |
*/ | |
protected ArrayInitializer initializer; | |
/** | |
* 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; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected ArrayCreationImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return JavaPackage.eINSTANCE.getArrayCreation(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<Expression> getDimensions() { | |
if (dimensions == null) { | |
dimensions = new EObjectContainmentEList<Expression>(Expression.class, this, JavaPackage.ARRAY_CREATION__DIMENSIONS); | |
} | |
return dimensions; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public ArrayInitializer getInitializer() { | |
return initializer; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public NotificationChain basicSetInitializer(ArrayInitializer newInitializer, NotificationChain msgs) { | |
ArrayInitializer oldInitializer = initializer; | |
initializer = newInitializer; | |
if (eNotificationRequired()) { | |
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, JavaPackage.ARRAY_CREATION__INITIALIZER, oldInitializer, newInitializer); | |
if (msgs == null) msgs = notification; else msgs.add(notification); | |
} | |
return msgs; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setInitializer(ArrayInitializer newInitializer) { | |
if (newInitializer != initializer) { | |
NotificationChain msgs = null; | |
if (initializer != null) | |
msgs = ((InternalEObject)initializer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - JavaPackage.ARRAY_CREATION__INITIALIZER, null, msgs); | |
if (newInitializer != null) | |
msgs = ((InternalEObject)newInitializer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.ARRAY_CREATION__INITIALIZER, null, msgs); | |
msgs = basicSetInitializer(newInitializer, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.ARRAY_CREATION__INITIALIZER, newInitializer, newInitializer)); | |
} | |
/** | |
* <!-- 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.ARRAY_CREATION__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.ARRAY_CREATION__TYPE, null, msgs); | |
if (newType != null) | |
msgs = ((InternalEObject)newType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JavaPackage.ARRAY_CREATION__TYPE, null, msgs); | |
msgs = basicSetType(newType, msgs); | |
if (msgs != null) msgs.dispatch(); | |
} | |
else if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, JavaPackage.ARRAY_CREATION__TYPE, newType, newType)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case JavaPackage.ARRAY_CREATION__DIMENSIONS: | |
return ((InternalEList<?>)getDimensions()).basicRemove(otherEnd, msgs); | |
case JavaPackage.ARRAY_CREATION__INITIALIZER: | |
return basicSetInitializer(null, msgs); | |
case JavaPackage.ARRAY_CREATION__TYPE: | |
return basicSetType(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.ARRAY_CREATION__DIMENSIONS: | |
return getDimensions(); | |
case JavaPackage.ARRAY_CREATION__INITIALIZER: | |
return getInitializer(); | |
case JavaPackage.ARRAY_CREATION__TYPE: | |
return getType(); | |
} | |
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.ARRAY_CREATION__DIMENSIONS: | |
getDimensions().clear(); | |
getDimensions().addAll((Collection<? extends Expression>)newValue); | |
return; | |
case JavaPackage.ARRAY_CREATION__INITIALIZER: | |
setInitializer((ArrayInitializer)newValue); | |
return; | |
case JavaPackage.ARRAY_CREATION__TYPE: | |
setType((TypeAccess)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case JavaPackage.ARRAY_CREATION__DIMENSIONS: | |
getDimensions().clear(); | |
return; | |
case JavaPackage.ARRAY_CREATION__INITIALIZER: | |
setInitializer((ArrayInitializer)null); | |
return; | |
case JavaPackage.ARRAY_CREATION__TYPE: | |
setType((TypeAccess)null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case JavaPackage.ARRAY_CREATION__DIMENSIONS: | |
return dimensions != null && !dimensions.isEmpty(); | |
case JavaPackage.ARRAY_CREATION__INITIALIZER: | |
return initializer != null; | |
case JavaPackage.ARRAY_CREATION__TYPE: | |
return type != null; | |
} | |
return super.eIsSet(featureID); | |
} | |
} //ArrayCreationImpl |