blob: 039fce53514b0b152b595a2155c5d4674a80cb58 [file] [log] [blame]
/**
* *******************************************************************************
* 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:
*
* Fabien Giquel (Mia-Software) - initial API and implementation
* Gregoire DUPE (Mia-Software) - initial API and implementation
* *******************************************************************************
*
* $Id$
*/
package org.eclipse.gmt.modisco.java.nousages.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.ImportDeclaration;
import org.eclipse.gmt.modisco.java.ParameterizedType;
import org.eclipse.gmt.modisco.java.TypeAccess;
import org.eclipse.gmt.modisco.java.nousages.meta.JavaPackage;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Parameterized Type</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>
* {@link org.eclipse.gmt.modisco.java.nousages.impl.ParameterizedTypeImpl#getType
* <em>Type</em>}</li>
* <li>
* {@link org.eclipse.gmt.modisco.java.nousages.impl.ParameterizedTypeImpl#getTypeArguments
* <em>Type Arguments</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ParameterizedTypeImpl extends TypeImpl implements
ParameterizedType {
/**
* 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 #getTypeArguments()
* <em>Type Arguments</em>}' containment reference list. <!-- begin-user-doc
* --> <!-- end-user-doc -->
*
* @see #getTypeArguments()
* @generated
* @ordered
*/
protected EList<TypeAccess> typeArguments;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected ParameterizedTypeImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return JavaPackage.eINSTANCE.getParameterizedType();
}
/**
* <!-- 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.PARAMETERIZED_TYPE__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.PARAMETERIZED_TYPE__TYPE, null,
msgs);
if (newType != null)
msgs = ((InternalEObject) newType).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE
- JavaPackage.PARAMETERIZED_TYPE__TYPE, null,
msgs);
msgs = basicSetType(newType, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
JavaPackage.PARAMETERIZED_TYPE__TYPE, newType, newType));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public EList<TypeAccess> getTypeArguments() {
if (typeArguments == null) {
typeArguments = new EObjectContainmentEList<TypeAccess>(
TypeAccess.class, this,
JavaPackage.PARAMETERIZED_TYPE__TYPE_ARGUMENTS);
}
return typeArguments;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case JavaPackage.PARAMETERIZED_TYPE__TYPE:
return basicSetType(null, msgs);
case JavaPackage.PARAMETERIZED_TYPE__TYPE_ARGUMENTS:
return ((InternalEList<?>) getTypeArguments()).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.PARAMETERIZED_TYPE__TYPE:
return getType();
case JavaPackage.PARAMETERIZED_TYPE__TYPE_ARGUMENTS:
return getTypeArguments();
}
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.PARAMETERIZED_TYPE__TYPE:
setType((TypeAccess) newValue);
return;
case JavaPackage.PARAMETERIZED_TYPE__TYPE_ARGUMENTS:
getTypeArguments().clear();
getTypeArguments().addAll(
(Collection<? extends TypeAccess>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case JavaPackage.PARAMETERIZED_TYPE__TYPE:
setType((TypeAccess) null);
return;
case JavaPackage.PARAMETERIZED_TYPE__TYPE_ARGUMENTS:
getTypeArguments().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case JavaPackage.PARAMETERIZED_TYPE__TYPE:
return type != null;
case JavaPackage.PARAMETERIZED_TYPE__TYPE_ARGUMENTS:
return typeArguments != null && !typeArguments.isEmpty();
}
return super.eIsSet(featureID);
}
public EList<TypeAccess> getUsagesInTypeAccess() {
// no usage references
return null;
}
public EList<ImportDeclaration> getUsagesInImports() {
// no usage references
return null;
}
} // ParameterizedTypeImpl