blob: 1769478e756078dfe5e29339219ab09530e9c7e1 [file] [log] [blame]
/**
* <copyright>
* Copyright (c) 2009, 2010 Open Canarias, S.L.
* 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:
* Adolfo Sanchez-Barbudo Herrera - Initial API and implementation
*
* </copyright>
*/
package org.eclipse.modisco.omg.gastm.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.modisco.omg.gastm.FormalParameterType;
import org.eclipse.modisco.omg.gastm.FunctionType;
import org.eclipse.modisco.omg.gastm.GASTMPackage;
import org.eclipse.modisco.omg.gastm.TypeReference;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Function Type</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.modisco.omg.gastm.impl.FunctionTypeImpl#getReturnType <em>Return Type</em>}</li>
* <li>{@link org.eclipse.modisco.omg.gastm.impl.FunctionTypeImpl#getParameterTypes <em>Parameter Types</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class FunctionTypeImpl extends TypeImpl implements FunctionType {
/**
* The cached value of the '{@link #getReturnType() <em>Return Type</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReturnType()
* @generated
* @ordered
*/
protected TypeReference returnType;
/**
* The cached value of the '{@link #getParameterTypes() <em>Parameter Types</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParameterTypes()
* @generated
* @ordered
*/
protected EList<FormalParameterType> parameterTypes;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected FunctionTypeImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return GASTMPackage.eINSTANCE.getFunctionType();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TypeReference getReturnType() {
return returnType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReturnType(TypeReference newReturnType, NotificationChain msgs) {
TypeReference oldReturnType = returnType;
returnType = newReturnType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, GASTMPackage.FUNCTION_TYPE__RETURN_TYPE, oldReturnType, newReturnType);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReturnType(TypeReference newReturnType) {
if (newReturnType != returnType) {
NotificationChain msgs = null;
if (returnType != null)
msgs = ((InternalEObject)returnType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - GASTMPackage.FUNCTION_TYPE__RETURN_TYPE, null, msgs);
if (newReturnType != null)
msgs = ((InternalEObject)newReturnType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - GASTMPackage.FUNCTION_TYPE__RETURN_TYPE, null, msgs);
msgs = basicSetReturnType(newReturnType, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, GASTMPackage.FUNCTION_TYPE__RETURN_TYPE, newReturnType, newReturnType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<FormalParameterType> getParameterTypes() {
if (parameterTypes == null) {
parameterTypes = new EObjectContainmentEList<FormalParameterType>(FormalParameterType.class, this, GASTMPackage.FUNCTION_TYPE__PARAMETER_TYPES);
}
return parameterTypes;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case GASTMPackage.FUNCTION_TYPE__RETURN_TYPE:
return basicSetReturnType(null, msgs);
case GASTMPackage.FUNCTION_TYPE__PARAMETER_TYPES:
return ((InternalEList<?>)getParameterTypes()).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 GASTMPackage.FUNCTION_TYPE__RETURN_TYPE:
return getReturnType();
case GASTMPackage.FUNCTION_TYPE__PARAMETER_TYPES:
return getParameterTypes();
}
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 GASTMPackage.FUNCTION_TYPE__RETURN_TYPE:
setReturnType((TypeReference)newValue);
return;
case GASTMPackage.FUNCTION_TYPE__PARAMETER_TYPES:
getParameterTypes().clear();
getParameterTypes().addAll((Collection<? extends FormalParameterType>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case GASTMPackage.FUNCTION_TYPE__RETURN_TYPE:
setReturnType((TypeReference)null);
return;
case GASTMPackage.FUNCTION_TYPE__PARAMETER_TYPES:
getParameterTypes().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case GASTMPackage.FUNCTION_TYPE__RETURN_TYPE:
return returnType != null;
case GASTMPackage.FUNCTION_TYPE__PARAMETER_TYPES:
return parameterTypes != null && !parameterTypes.isEmpty();
}
return super.eIsSet(featureID);
}
} //FunctionTypeImpl