blob: 6a7cfbd6db7722874053716c4654b58951823e88 [file] [log] [blame]
/**
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* 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
*
* Based on ideas from Xtext, Xtend, Xcore
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - Initial implementation
*
*/
package org.eclipse.osbp.xtext.entitymock.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.osbp.dsl.semantic.entity.LEntityAttribute;
import org.eclipse.osbp.xtext.entitymock.EntityMockDSLPackage;
import org.eclipse.osbp.xtext.entitymock.EntityMockEntityFunction;
import org.eclipse.osbp.xtext.entitymock.EntityMockEntityFunctionParameter;
import org.eclipse.xtext.xbase.XExpression;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Entity Mock Entity Function</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.osbp.xtext.entitymock.impl.EntityMockEntityFunctionImpl#getAttributeRef <em>Attribute Ref</em>}</li>
* <li>{@link org.eclipse.osbp.xtext.entitymock.impl.EntityMockEntityFunctionImpl#getParams <em>Params</em>}</li>
* <li>{@link org.eclipse.osbp.xtext.entitymock.impl.EntityMockEntityFunctionImpl#getBody <em>Body</em>}</li>
* </ul>
*
* @generated
*/
public class EntityMockEntityFunctionImpl extends IEntityMockEntityUsableImpl implements EntityMockEntityFunction {
/**
* The cached value of the '{@link #getAttributeRef() <em>Attribute Ref</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getAttributeRef()
* @generated
* @ordered
*/
protected LEntityAttribute attributeRef;
/**
* 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<EntityMockEntityFunctionParameter> params;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected XExpression body;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EntityMockEntityFunctionImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return EntityMockDSLPackage.Literals.ENTITY_MOCK_ENTITY_FUNCTION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LEntityAttribute getAttributeRef() {
if (attributeRef != null && attributeRef.eIsProxy()) {
InternalEObject oldAttributeRef = (InternalEObject)attributeRef;
attributeRef = (LEntityAttribute)eResolveProxy(oldAttributeRef);
if (attributeRef != oldAttributeRef) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__ATTRIBUTE_REF, oldAttributeRef, attributeRef));
}
}
return attributeRef;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LEntityAttribute basicGetAttributeRef() {
return attributeRef;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAttributeRef(LEntityAttribute newAttributeRef) {
LEntityAttribute oldAttributeRef = attributeRef;
attributeRef = newAttributeRef;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__ATTRIBUTE_REF, oldAttributeRef, attributeRef));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<EntityMockEntityFunctionParameter> getParams() {
if (params == null) {
params = new EObjectContainmentEList<EntityMockEntityFunctionParameter>(EntityMockEntityFunctionParameter.class, this, EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__PARAMS);
}
return params;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public XExpression getBody() {
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBody(XExpression newBody, NotificationChain msgs) {
XExpression oldBody = body;
body = newBody;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY, oldBody, newBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBody(XExpression newBody) {
if (newBody != body) {
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY, newBody, newBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__PARAMS:
return ((InternalEList<?>)getParams()).basicRemove(otherEnd, msgs);
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY:
return basicSetBody(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 EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__ATTRIBUTE_REF:
if (resolve) return getAttributeRef();
return basicGetAttributeRef();
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__PARAMS:
return getParams();
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY:
return getBody();
}
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 EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__ATTRIBUTE_REF:
setAttributeRef((LEntityAttribute)newValue);
return;
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__PARAMS:
getParams().clear();
getParams().addAll((Collection<? extends EntityMockEntityFunctionParameter>)newValue);
return;
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY:
setBody((XExpression)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__ATTRIBUTE_REF:
setAttributeRef((LEntityAttribute)null);
return;
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__PARAMS:
getParams().clear();
return;
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY:
setBody((XExpression)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__ATTRIBUTE_REF:
return attributeRef != null;
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__PARAMS:
return params != null && !params.isEmpty();
case EntityMockDSLPackage.ENTITY_MOCK_ENTITY_FUNCTION__BODY:
return body != null;
}
return super.eIsSet(featureID);
}
} //EntityMockEntityFunctionImpl