/**
* *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* *
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*/
package org.thingml.xtext.thingML.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.thingml.xtext.thingML.ArrayIndex;
import org.thingml.xtext.thingML.Expression;
import org.thingml.xtext.thingML.ThingMLPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Array Index</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.thingml.xtext.thingML.impl.ArrayIndexImpl#getArray <em>Array</em>}</li>
* <li>{@link org.thingml.xtext.thingML.impl.ArrayIndexImpl#getIndex <em>Index</em>}</li>
* </ul>
*
* @generated
*/
public class ArrayIndexImpl extends ExpressionImpl implements ArrayIndex
{
/**
* The cached value of the '{@link #getArray() <em>Array</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArray()
* @generated
* @ordered
*/
protected Expression array;
/**
* The cached value of the '{@link #getIndex() <em>Index</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIndex()
* @generated
* @ordered
*/
protected Expression index;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ArrayIndexImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return ThingMLPackage.Literals.ARRAY_INDEX;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Expression getArray()
{
return array;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetArray(Expression newArray, NotificationChain msgs)
{
Expression oldArray = array;
array = newArray;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThingMLPackage.ARRAY_INDEX__ARRAY, oldArray, newArray);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setArray(Expression newArray)
{
if (newArray != array)
{
NotificationChain msgs = null;
if (array != null)
msgs = ((InternalEObject)array).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.ARRAY_INDEX__ARRAY, null, msgs);
if (newArray != null)
msgs = ((InternalEObject)newArray).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.ARRAY_INDEX__ARRAY, null, msgs);
msgs = basicSetArray(newArray, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.ARRAY_INDEX__ARRAY, newArray, newArray));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Expression getIndex()
{
return index;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetIndex(Expression newIndex, NotificationChain msgs)
{
Expression oldIndex = index;
index = newIndex;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThingMLPackage.ARRAY_INDEX__INDEX, oldIndex, newIndex);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setIndex(Expression newIndex)
{
if (newIndex != index)
{
NotificationChain msgs = null;
if (index != null)
msgs = ((InternalEObject)index).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.ARRAY_INDEX__INDEX, null, msgs);
if (newIndex != null)
msgs = ((InternalEObject)newIndex).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.ARRAY_INDEX__INDEX, null, msgs);
msgs = basicSetIndex(newIndex, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.ARRAY_INDEX__INDEX, newIndex, newIndex));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case ThingMLPackage.ARRAY_INDEX__ARRAY:
return basicSetArray(null, msgs);
case ThingMLPackage.ARRAY_INDEX__INDEX:
return basicSetIndex(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 ThingMLPackage.ARRAY_INDEX__ARRAY:
return getArray();
case ThingMLPackage.ARRAY_INDEX__INDEX:
return getIndex();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case ThingMLPackage.ARRAY_INDEX__ARRAY:
setArray((Expression)newValue);
return;
case ThingMLPackage.ARRAY_INDEX__INDEX:
setIndex((Expression)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case ThingMLPackage.ARRAY_INDEX__ARRAY:
setArray((Expression)null);
return;
case ThingMLPackage.ARRAY_INDEX__INDEX:
setIndex((Expression)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case ThingMLPackage.ARRAY_INDEX__ARRAY:
return array != null;
case ThingMLPackage.ARRAY_INDEX__INDEX:
return index != null;
}
return super.eIsSet(featureID);
}
} //ArrayIndexImpl