blob: 8e6c986f77cb7fc8ba53a8e9024357ca9ef29dbc [file] [log] [blame]
/*
* Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
* 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:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.emf.cdo.expressions.impl;
import org.eclipse.emf.cdo.expressions.EvaluationContext;
import org.eclipse.emf.cdo.expressions.Expression;
import org.eclipse.emf.cdo.expressions.ExpressionsPackage;
import org.eclipse.emf.cdo.expressions.ListConstruction;
import org.eclipse.emf.internal.cdo.CDOObjectImpl;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.util.InternalEList;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>List Value</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.emf.cdo.expressions.impl.ListConstructionImpl#getElements <em>Elements</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ListConstructionImpl extends CDOObjectImpl implements ListConstruction
{
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ListConstructionImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return ExpressionsPackage.Literals.LIST_CONSTRUCTION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected int eStaticFeatureCount()
{
return 0;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
public EList<Expression> getElements()
{
return (EList<Expression>)eDynamicGet(ExpressionsPackage.LIST_CONSTRUCTION__ELEMENTS,
ExpressionsPackage.Literals.LIST_CONSTRUCTION__ELEMENTS, true, true);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public Object evaluate(EvaluationContext context)
{
EList<Object> result = new BasicEList<Object>();
for (Expression element : getElements())
{
result.add(element.evaluate(context));
}
return result;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case ExpressionsPackage.LIST_CONSTRUCTION__ELEMENTS:
return ((InternalEList<?>)getElements()).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 ExpressionsPackage.LIST_CONSTRUCTION__ELEMENTS:
return getElements();
}
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 ExpressionsPackage.LIST_CONSTRUCTION__ELEMENTS:
getElements().clear();
getElements().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 ExpressionsPackage.LIST_CONSTRUCTION__ELEMENTS:
getElements().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case ExpressionsPackage.LIST_CONSTRUCTION__ELEMENTS:
return !getElements().isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
{
switch (operationID)
{
case ExpressionsPackage.LIST_CONSTRUCTION___EVALUATE__EVALUATIONCONTEXT:
return evaluate((EvaluationContext)arguments.get(0));
}
return super.eInvoke(operationID, arguments);
}
} // ListValueImpl