/** | |
* | |
* Copyright (c) 2009 Hatha Systems. | |
* 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: | |
* Nikolai Mansourov (Hatha Systems) - initial API and implementation | |
* Gabriel Barbier (Mia-Software) - minor evolutions for version 1.1 | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.gmt.modisco.omg.kdm.code.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.eclipse.gmt.modisco.omg.kdm.code.AbstractCodeElement; | |
import org.eclipse.gmt.modisco.omg.kdm.code.CodePackage; | |
import org.eclipse.gmt.modisco.omg.kdm.code.ControlElement; | |
import org.eclipse.gmt.modisco.omg.kdm.code.Datatype; | |
/** | |
* <!-- begin-user-doc --> | |
* An implementation of the model object '<em><b>Control Element</b></em>'. | |
* <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.gmt.modisco.omg.kdm.code.impl.ControlElementImpl#getType <em>Type</em>}</li> | |
* <li>{@link org.eclipse.gmt.modisco.omg.kdm.code.impl.ControlElementImpl#getCodeElement <em>Code Element</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class ControlElementImpl extends ComputationalObjectImpl implements ControlElement { | |
/** | |
* The cached value of the '{@link #getType() <em>Type</em>}' reference. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getType() | |
* @generated | |
* @ordered | |
*/ | |
protected Datatype type; | |
/** | |
* The cached value of the '{@link #getCodeElement() <em>Code Element</em>}' containment reference list. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @see #getCodeElement() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<AbstractCodeElement> codeElement; | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected ControlElementImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return CodePackage.Literals.CONTROL_ELEMENT; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Datatype getType() { | |
if (type != null && type.eIsProxy()) { | |
InternalEObject oldType = (InternalEObject)type; | |
type = (Datatype)eResolveProxy(oldType); | |
if (type != oldType) { | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.RESOLVE, CodePackage.CONTROL_ELEMENT__TYPE, oldType, type)); | |
} | |
} | |
return type; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public Datatype basicGetType() { | |
return type; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setType(Datatype newType) { | |
Datatype oldType = type; | |
type = newType; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, CodePackage.CONTROL_ELEMENT__TYPE, oldType, type)); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<AbstractCodeElement> getCodeElement() { | |
if (codeElement == null) { | |
codeElement = new EObjectContainmentEList<AbstractCodeElement>(AbstractCodeElement.class, this, CodePackage.CONTROL_ELEMENT__CODE_ELEMENT); | |
} | |
return codeElement; | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case CodePackage.CONTROL_ELEMENT__CODE_ELEMENT: | |
return ((InternalEList<?>)getCodeElement()).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 CodePackage.CONTROL_ELEMENT__TYPE: | |
if (resolve) return getType(); | |
return basicGetType(); | |
case CodePackage.CONTROL_ELEMENT__CODE_ELEMENT: | |
return getCodeElement(); | |
} | |
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 CodePackage.CONTROL_ELEMENT__TYPE: | |
setType((Datatype)newValue); | |
return; | |
case CodePackage.CONTROL_ELEMENT__CODE_ELEMENT: | |
getCodeElement().clear(); | |
getCodeElement().addAll((Collection<? extends AbstractCodeElement>)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case CodePackage.CONTROL_ELEMENT__TYPE: | |
setType((Datatype)null); | |
return; | |
case CodePackage.CONTROL_ELEMENT__CODE_ELEMENT: | |
getCodeElement().clear(); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case CodePackage.CONTROL_ELEMENT__TYPE: | |
return type != null; | |
case CodePackage.CONTROL_ELEMENT__CODE_ELEMENT: | |
return codeElement != null && !codeElement.isEmpty(); | |
} | |
return super.eIsSet(featureID); | |
} | |
} //ControlElementImpl |