/** * 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.sintef.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.sintef.thingml.LocalVariable; import org.sintef.thingml.SendAction; import org.sintef.thingml.Source; import org.sintef.thingml.Stream; import org.sintef.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.sintef.thingml.impl.StreamImpl#getSelection <em>Selection</em>}</li> * <li>{@link org.sintef.thingml.impl.StreamImpl#getOutput <em>Output</em>}</li> * <li>{@link org.sintef.thingml.impl.StreamImpl#getInput <em>Input</em>}</li> * <li>{@link org.sintef.thingml.impl.StreamImpl#isDynamic <em>Dynamic</em>}</li> * </ul> * * @generated */ public class StreamImpl extends AnnotatedElementImpl implements Stream { /** * 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; /** * 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 default value of the '{@link #isDynamic() <em>Dynamic</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isDynamic() * @generated * @ordered */ protected static final boolean DYNAMIC_EDEFAULT = false; /** * The cached value of the '{@link #isDynamic() <em>Dynamic</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #isDynamic() * @generated * @ordered */ protected boolean dynamic = DYNAMIC_EDEFAULT; /** * <!-- 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 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 */ 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 boolean isDynamic() { return dynamic; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setDynamic(boolean newDynamic) { boolean oldDynamic = dynamic; dynamic = newDynamic; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ThingmlPackage.STREAM__DYNAMIC, oldDynamic, dynamic)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ThingmlPackage.STREAM__SELECTION: return ((InternalEList<?>)getSelection()).basicRemove(otherEnd, msgs); case ThingmlPackage.STREAM__OUTPUT: return basicSetOutput(null, msgs); case ThingmlPackage.STREAM__INPUT: return basicSetInput(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__SELECTION: return getSelection(); case ThingmlPackage.STREAM__OUTPUT: return getOutput(); case ThingmlPackage.STREAM__INPUT: return getInput(); case ThingmlPackage.STREAM__DYNAMIC: return isDynamic(); } 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__SELECTION: getSelection().clear(); getSelection().addAll((Collection<? extends LocalVariable>)newValue); return; case ThingmlPackage.STREAM__OUTPUT: setOutput((SendAction)newValue); return; case ThingmlPackage.STREAM__INPUT: setInput((Source)newValue); return; case ThingmlPackage.STREAM__DYNAMIC: setDynamic((Boolean)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ThingmlPackage.STREAM__SELECTION: getSelection().clear(); return; case ThingmlPackage.STREAM__OUTPUT: setOutput((SendAction)null); return; case ThingmlPackage.STREAM__INPUT: setInput((Source)null); return; case ThingmlPackage.STREAM__DYNAMIC: setDynamic(DYNAMIC_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ThingmlPackage.STREAM__SELECTION: return selection != null && !selection.isEmpty(); case ThingmlPackage.STREAM__OUTPUT: return output != null; case ThingmlPackage.STREAM__INPUT: return input != null; case ThingmlPackage.STREAM__DYNAMIC: return dynamic != DYNAMIC_EDEFAULT; } 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(" (dynamic: "); result.append(dynamic); result.append(')'); return result.toString(); } } //StreamImpl