blob: 297f8fc9f137ae8fac0ae9ed77385be49c2ed7b4 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2014 Bosch Software Innovations GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* The Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*
*******************************************************************************/
/**
*/
package org.eclipse.vorto.functionblock.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.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.vorto.functionblock.FunctionblockPackage;
import org.eclipse.vorto.functionblock.Operation;
import org.eclipse.vorto.functionblock.Parameter;
import org.eclipse.vorto.functionblock.ReturnType;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Operation</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.vorto.functionblock.impl.OperationImpl#getMethodName <em>Method Name</em>}</li>
* <li>{@link org.eclipse.vorto.functionblock.impl.OperationImpl#getParams <em>Params</em>}</li>
* <li>{@link org.eclipse.vorto.functionblock.impl.OperationImpl#getReturnType <em>Return Type</em>}</li>
* <li>{@link org.eclipse.vorto.functionblock.impl.OperationImpl#getDescription <em>Description</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class OperationImpl extends MinimalEObjectImpl.Container implements Operation {
/**
* The default value of the '{@link #getMethodName() <em>Method Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMethodName()
* @generated
* @ordered
*/
protected static final String METHOD_NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getMethodName() <em>Method Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMethodName()
* @generated
* @ordered
*/
protected String methodName = METHOD_NAME_EDEFAULT;
/**
* The cached value of the '{@link #getParams() <em>Params</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParams()
* @generated
* @ordered
*/
protected EList<Parameter> params;
/**
* The cached value of the '{@link #getReturnType() <em>Return Type</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReturnType()
* @generated
* @ordered
*/
protected ReturnType returnType;
/**
* The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDescription()
* @generated
* @ordered
*/
protected static final String DESCRIPTION_EDEFAULT = null;
/**
* The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDescription()
* @generated
* @ordered
*/
protected String description = DESCRIPTION_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected OperationImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return FunctionblockPackage.Literals.OPERATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getMethodName() {
return methodName;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMethodName(String newMethodName) {
String oldMethodName = methodName;
methodName = newMethodName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, FunctionblockPackage.OPERATION__METHOD_NAME, oldMethodName, methodName));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Parameter> getParams() {
if (params == null) {
params = new EObjectContainmentEList<Parameter>(Parameter.class, this, FunctionblockPackage.OPERATION__PARAMS);
}
return params;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ReturnType getReturnType() {
return returnType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReturnType(ReturnType newReturnType, NotificationChain msgs) {
ReturnType oldReturnType = returnType;
returnType = newReturnType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, FunctionblockPackage.OPERATION__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(ReturnType newReturnType) {
if (newReturnType != returnType) {
NotificationChain msgs = null;
if (returnType != null)
msgs = ((InternalEObject)returnType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - FunctionblockPackage.OPERATION__RETURN_TYPE, null, msgs);
if (newReturnType != null)
msgs = ((InternalEObject)newReturnType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - FunctionblockPackage.OPERATION__RETURN_TYPE, null, msgs);
msgs = basicSetReturnType(newReturnType, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, FunctionblockPackage.OPERATION__RETURN_TYPE, newReturnType, newReturnType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getDescription() {
return description;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDescription(String newDescription) {
String oldDescription = description;
description = newDescription;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, FunctionblockPackage.OPERATION__DESCRIPTION, oldDescription, description));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case FunctionblockPackage.OPERATION__PARAMS:
return ((InternalEList<?>)getParams()).basicRemove(otherEnd, msgs);
case FunctionblockPackage.OPERATION__RETURN_TYPE:
return basicSetReturnType(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 FunctionblockPackage.OPERATION__METHOD_NAME:
return getMethodName();
case FunctionblockPackage.OPERATION__PARAMS:
return getParams();
case FunctionblockPackage.OPERATION__RETURN_TYPE:
return getReturnType();
case FunctionblockPackage.OPERATION__DESCRIPTION:
return getDescription();
}
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 FunctionblockPackage.OPERATION__METHOD_NAME:
setMethodName((String)newValue);
return;
case FunctionblockPackage.OPERATION__PARAMS:
getParams().clear();
getParams().addAll((Collection<? extends Parameter>)newValue);
return;
case FunctionblockPackage.OPERATION__RETURN_TYPE:
setReturnType((ReturnType)newValue);
return;
case FunctionblockPackage.OPERATION__DESCRIPTION:
setDescription((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case FunctionblockPackage.OPERATION__METHOD_NAME:
setMethodName(METHOD_NAME_EDEFAULT);
return;
case FunctionblockPackage.OPERATION__PARAMS:
getParams().clear();
return;
case FunctionblockPackage.OPERATION__RETURN_TYPE:
setReturnType((ReturnType)null);
return;
case FunctionblockPackage.OPERATION__DESCRIPTION:
setDescription(DESCRIPTION_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case FunctionblockPackage.OPERATION__METHOD_NAME:
return METHOD_NAME_EDEFAULT == null ? methodName != null : !METHOD_NAME_EDEFAULT.equals(methodName);
case FunctionblockPackage.OPERATION__PARAMS:
return params != null && !params.isEmpty();
case FunctionblockPackage.OPERATION__RETURN_TYPE:
return returnType != null;
case FunctionblockPackage.OPERATION__DESCRIPTION:
return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (methodName: ");
result.append(methodName);
result.append(", description: ");
result.append(description);
result.append(')');
return result.toString();
}
} //OperationImpl