/**
* 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.
*/
/**
* generated by Xtext 2.10.0
*/
package org.thingml.xtext.thingML.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.thingml.xtext.thingML.LocalVariable;
import org.thingml.xtext.thingML.SendAction;
import org.thingml.xtext.thingML.Source;
import org.thingml.xtext.thingML.Stream;
import org.thingml.xtext.thingML.ThingMLPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Stream</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.thingml.xtext.thingML.impl.StreamImpl#getName <em>Name</em>}</li>
* <li>{@link org.thingml.xtext.thingML.impl.StreamImpl#getInput <em>Input</em>}</li>
* <li>{@link org.thingml.xtext.thingML.impl.StreamImpl#getSelection <em>Selection</em>}</li>
* <li>{@link org.thingml.xtext.thingML.impl.StreamImpl#getOutput <em>Output</em>}</li>
* </ul>
*
* @generated
*/
public class StreamImpl extends AnnotatedElementImpl implements Stream
{
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_EDEFAULT;
/**
* The cached value of the '{@link #getInput() <em>Input</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInput()
* @generated
* @ordered
*/
protected Source input;
/**
* The cached value of the '{@link #getSelection() <em>Selection</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSelection()
* @generated
* @ordered
*/
protected EList<LocalVariable> selection;
/**
* The cached value of the '{@link #getOutput() <em>Output</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOutput()
* @generated
* @ordered
*/
protected SendAction output;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected StreamImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return ThingMLPackage.Literals.STREAM;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName()
{
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName)
{
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.STREAM__NAME, oldName, name));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Source getInput()
{
return input;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetInput(Source newInput, NotificationChain msgs)
{
Source oldInput = input;
input = newInput;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThingMLPackage.STREAM__INPUT, oldInput, newInput);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setInput(Source newInput)
{
if (newInput != input)
{
NotificationChain msgs = null;
if (input != null)
msgs = ((InternalEObject)input).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.STREAM__INPUT, null, msgs);
if (newInput != null)
msgs = ((InternalEObject)newInput).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.STREAM__INPUT, null, msgs);
msgs = basicSetInput(newInput, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.STREAM__INPUT, newInput, newInput));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<LocalVariable> getSelection()
{
if (selection == null)
{
selection = new EObjectContainmentEList<LocalVariable>(LocalVariable.class, this, ThingMLPackage.STREAM__SELECTION);
}
return selection;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public SendAction getOutput()
{
return output;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOutput(SendAction newOutput, NotificationChain msgs)
{
SendAction oldOutput = output;
output = newOutput;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ThingMLPackage.STREAM__OUTPUT, oldOutput, newOutput);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOutput(SendAction newOutput)
{
if (newOutput != output)
{
NotificationChain msgs = null;
if (output != null)
msgs = ((InternalEObject)output).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.STREAM__OUTPUT, null, msgs);
if (newOutput != null)
msgs = ((InternalEObject)newOutput).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ThingMLPackage.STREAM__OUTPUT, null, msgs);
msgs = basicSetOutput(newOutput, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ThingMLPackage.STREAM__OUTPUT, newOutput, newOutput));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case ThingMLPackage.STREAM__INPUT:
return basicSetInput(null, msgs);
case ThingMLPackage.STREAM__SELECTION:
return ((InternalEList<?>)getSelection()).basicRemove(otherEnd, msgs);
case ThingMLPackage.STREAM__OUTPUT:
return basicSetOutput(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.STREAM__NAME:
return getName();
case ThingMLPackage.STREAM__INPUT:
return getInput();
case ThingMLPackage.STREAM__SELECTION:
return getSelection();
case ThingMLPackage.STREAM__OUTPUT:
return getOutput();
}
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 ThingMLPackage.STREAM__NAME:
setName((String)newValue);
return;
case ThingMLPackage.STREAM__INPUT:
setInput((Source)newValue);
return;
case ThingMLPackage.STREAM__SELECTION:
getSelection().clear();
getSelection().addAll((Collection<? extends LocalVariable>)newValue);
return;
case ThingMLPackage.STREAM__OUTPUT:
setOutput((SendAction)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case ThingMLPackage.STREAM__NAME:
setName(NAME_EDEFAULT);
return;
case ThingMLPackage.STREAM__INPUT:
setInput((Source)null);
return;
case ThingMLPackage.STREAM__SELECTION:
getSelection().clear();
return;
case ThingMLPackage.STREAM__OUTPUT:
setOutput((SendAction)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case ThingMLPackage.STREAM__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case ThingMLPackage.STREAM__INPUT:
return input != null;
case ThingMLPackage.STREAM__SELECTION:
return selection != null && !selection.isEmpty();
case ThingMLPackage.STREAM__OUTPUT:
return output != null;
}
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(" (name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //StreamImpl