blob: b9f4f30a675ea05feb7a35de0a5d2914dd0b4d80 [file] [log] [blame]
/**
* Copyright (c) 2020 CEA LIST.
*
* 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\n\nContributors:
* Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
* - Initial API and Implementation
*/
package org.eclipse.efm.ecore.formalml.expression.impl;
import java.util.Collection;
import org.eclipse.efm.ecore.formalml.datatype.DataType;
import org.eclipse.efm.ecore.formalml.expression.Expression;
import org.eclipse.efm.ecore.formalml.expression.ExpressionPackage;
import org.eclipse.efm.ecore.formalml.expression.LiteralCollectionExpression;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Literal Collection Expression</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.efm.ecore.formalml.expression.impl.LiteralCollectionExpressionImpl#getDatatype <em>Datatype</em>}</li>
* <li>{@link org.eclipse.efm.ecore.formalml.expression.impl.LiteralCollectionExpressionImpl#getValue <em>Value</em>}</li>
* </ul>
*
* @generated
*/
public class LiteralCollectionExpressionImpl extends LiteralExpressionImpl implements LiteralCollectionExpression {
/**
* The cached value of the '{@link #getDatatype() <em>Datatype</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDatatype()
* @generated
* @ordered
*/
protected DataType datatype;
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected EList<Expression> value;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected LiteralCollectionExpressionImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExpressionPackage.Literals.LITERAL_COLLECTION_EXPRESSION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public DataType getDatatype() {
return datatype;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetDatatype(DataType newDatatype, NotificationChain msgs) {
DataType oldDatatype = datatype;
datatype = newDatatype;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE, oldDatatype, newDatatype);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setDatatype(DataType newDatatype) {
if (newDatatype != datatype) {
NotificationChain msgs = null;
if (datatype != null)
msgs = ((InternalEObject)datatype).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE, null, msgs);
if (newDatatype != null)
msgs = ((InternalEObject)newDatatype).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE, null, msgs);
msgs = basicSetDatatype(newDatatype, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE, newDatatype, newDatatype));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<Expression> getValue() {
if (value == null) {
value = new EObjectContainmentEList<Expression>(Expression.class, this, ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__VALUE);
}
return value;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE:
return basicSetDatatype(null, msgs);
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__VALUE:
return ((InternalEList<?>)getValue()).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 ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE:
return getDatatype();
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__VALUE:
return getValue();
}
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 ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE:
setDatatype((DataType)newValue);
return;
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__VALUE:
getValue().clear();
getValue().addAll((Collection<? extends Expression>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE:
setDatatype((DataType)null);
return;
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__VALUE:
getValue().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__DATATYPE:
return datatype != null;
case ExpressionPackage.LITERAL_COLLECTION_EXPRESSION__VALUE:
return value != null && !value.isEmpty();
}
return super.eIsSet(featureID);
}
} //LiteralCollectionExpressionImpl