blob: e78dc75368124c4ec09b41b08f0405d7f0b0a6d3 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2015 Xored Software Inc 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:
* Xored Software Inc - initial API and implementation and/or initial documentation
*******************************************************************************/
/**
*/
package org.eclipse.rcptt.ecl.core.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.EObject;
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.eclipse.rcptt.ecl.core.Case;
import org.eclipse.rcptt.ecl.core.Command;
import org.eclipse.rcptt.ecl.core.CorePackage;
import org.eclipse.rcptt.ecl.core.Switch;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Switch</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.rcptt.ecl.core.impl.SwitchImpl#getInput <em>Input</em>}</li>
* <li>{@link org.eclipse.rcptt.ecl.core.impl.SwitchImpl#getItems <em>Items</em>}</li>
* <li>{@link org.eclipse.rcptt.ecl.core.impl.SwitchImpl#getDefault <em>Default</em>}</li>
* </ul>
*
* @generated
*/
public class SwitchImpl extends CommandImpl implements Switch {
/**
* The cached value of the '{@link #getInput() <em>Input</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInput()
* @generated
* @ordered
*/
protected EObject input;
/**
* The cached value of the '{@link #getItems() <em>Items</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getItems()
* @generated
* @ordered
*/
protected EList<Case> items;
/**
* The cached value of the '{@link #getDefault() <em>Default</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDefault()
* @generated
* @ordered
*/
protected Command default_;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SwitchImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return CorePackage.Literals.SWITCH;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<Case> getItems() {
if (items == null) {
items = new EObjectContainmentEList<Case>(Case.class, this, CorePackage.SWITCH__ITEMS);
}
return items;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Command getDefault() {
return default_;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetDefault(Command newDefault, NotificationChain msgs) {
Command oldDefault = default_;
default_ = newDefault;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CorePackage.SWITCH__DEFAULT, oldDefault, newDefault);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setDefault(Command newDefault) {
if (newDefault != default_) {
NotificationChain msgs = null;
if (default_ != null)
msgs = ((InternalEObject)default_).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CorePackage.SWITCH__DEFAULT, null, msgs);
if (newDefault != null)
msgs = ((InternalEObject)newDefault).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CorePackage.SWITCH__DEFAULT, null, msgs);
msgs = basicSetDefault(newDefault, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.SWITCH__DEFAULT, newDefault, newDefault));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EObject getInput() {
if (input != null && input.eIsProxy()) {
InternalEObject oldInput = (InternalEObject)input;
input = eResolveProxy(oldInput);
if (input != oldInput) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, CorePackage.SWITCH__INPUT, oldInput, input));
}
}
return input;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EObject basicGetInput() {
return input;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setInput(EObject newInput) {
EObject oldInput = input;
input = newInput;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.SWITCH__INPUT, oldInput, input));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CorePackage.SWITCH__ITEMS:
return ((InternalEList<?>)getItems()).basicRemove(otherEnd, msgs);
case CorePackage.SWITCH__DEFAULT:
return basicSetDefault(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 CorePackage.SWITCH__INPUT:
if (resolve) return getInput();
return basicGetInput();
case CorePackage.SWITCH__ITEMS:
return getItems();
case CorePackage.SWITCH__DEFAULT:
return getDefault();
}
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 CorePackage.SWITCH__INPUT:
setInput((EObject)newValue);
return;
case CorePackage.SWITCH__ITEMS:
getItems().clear();
getItems().addAll((Collection<? extends Case>)newValue);
return;
case CorePackage.SWITCH__DEFAULT:
setDefault((Command)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CorePackage.SWITCH__INPUT:
setInput((EObject)null);
return;
case CorePackage.SWITCH__ITEMS:
getItems().clear();
return;
case CorePackage.SWITCH__DEFAULT:
setDefault((Command)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CorePackage.SWITCH__INPUT:
return input != null;
case CorePackage.SWITCH__ITEMS:
return items != null && !items.isEmpty();
case CorePackage.SWITCH__DEFAULT:
return default_ != null;
}
return super.eIsSet(featureID);
}
} //SwitchImpl