/******************************************************************************* | |
* Copyright (c) 2011 Mia-Software. | |
* 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: | |
* Fabien Giquel (Mia-Software) - initial API and implementation | |
* Nicolas Bros (Mia-Software) - Bug 335003 - [Discoverer] : Existing Discoverers Refactoring based on new framework | |
*******************************************************************************/ | |
package org.eclipse.modisco.kdm.source.extension.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.impl.EObjectImpl; | |
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; | |
import org.eclipse.emf.ecore.util.InternalEList; | |
import org.eclipse.gmt.modisco.omg.kdm.source.SourceFile; | |
import org.eclipse.modisco.kdm.source.extension.ASTNodeSourceRegion; | |
import org.eclipse.modisco.kdm.source.extension.CodeUnit2File; | |
import org.eclipse.modisco.kdm.source.extension.ExtensionPackage; | |
/** | |
* <!-- begin-user-doc --> An implementation of the model object ' | |
* <em><b>Code Unit2 File</b></em>'. <!-- end-user-doc --> | |
* <p> | |
* The following features are implemented: | |
* <ul> | |
* <li>{@link org.eclipse.modisco.kdm.source.extension.impl.CodeUnit2FileImpl#getFile <em>File</em>}</li> | |
* <li>{@link org.eclipse.modisco.kdm.source.extension.impl.CodeUnit2FileImpl#getChildren <em>Children</em>}</li> | |
* <li>{@link org.eclipse.modisco.kdm.source.extension.impl.CodeUnit2FileImpl#getUnit <em>Unit</em>}</li> | |
* </ul> | |
* </p> | |
* | |
* @generated | |
*/ | |
public class CodeUnit2FileImpl extends EObjectImpl implements | |
CodeUnit2File { | |
/** | |
* The cached value of the '{@link #getFile() <em>File</em>}' reference. | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @see #getFile() | |
* @generated | |
* @ordered | |
*/ | |
protected SourceFile file; | |
/** | |
* The cached value of the '{@link #getChildren() <em>Children</em>}' containment reference list. | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @see #getChildren() | |
* @generated | |
* @ordered | |
*/ | |
protected EList<ASTNodeSourceRegion> children; | |
/** | |
* The cached value of the '{@link #getUnit() <em>Unit</em>}' reference. | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @see #getUnit() | |
* @generated | |
* @ordered | |
*/ | |
protected EObject unit; | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected CodeUnit2FileImpl() { | |
super(); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
protected EClass eStaticClass() { | |
return ExtensionPackage.Literals.CODE_UNIT2_FILE; | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public SourceFile getFile() { | |
if (file != null && file.eIsProxy()) { | |
InternalEObject oldFile = (InternalEObject)file; | |
file = (SourceFile)eResolveProxy(oldFile); | |
if (file != oldFile) { | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtensionPackage.CODE_UNIT2_FILE__FILE, oldFile, file)); | |
} | |
} | |
return file; | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public SourceFile basicGetFile() { | |
return file; | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setFile(SourceFile newFile) { | |
SourceFile oldFile = file; | |
file = newFile; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionPackage.CODE_UNIT2_FILE__FILE, oldFile, file)); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EList<ASTNodeSourceRegion> getChildren() { | |
if (children == null) { | |
children = new EObjectContainmentWithInverseEList<ASTNodeSourceRegion>(ASTNodeSourceRegion.class, this, ExtensionPackage.CODE_UNIT2_FILE__CHILDREN, ExtensionPackage.AST_NODE_SOURCE_REGION__PARENT); | |
} | |
return children; | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EObject getUnit() { | |
if (unit != null && unit.eIsProxy()) { | |
InternalEObject oldUnit = (InternalEObject)unit; | |
unit = eResolveProxy(oldUnit); | |
if (unit != oldUnit) { | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExtensionPackage.CODE_UNIT2_FILE__UNIT, oldUnit, unit)); | |
} | |
} | |
return unit; | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public EObject basicGetUnit() { | |
return unit; | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
public void setUnit(EObject newUnit) { | |
EObject oldUnit = unit; | |
unit = newUnit; | |
if (eNotificationRequired()) | |
eNotify(new ENotificationImpl(this, Notification.SET, ExtensionPackage.CODE_UNIT2_FILE__UNIT, oldUnit, unit)); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@SuppressWarnings("unchecked") | |
@Override | |
public NotificationChain eInverseAdd(InternalEObject otherEnd, | |
int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case ExtensionPackage.CODE_UNIT2_FILE__CHILDREN: | |
return ((InternalEList<InternalEObject>)(InternalEList<?>)getChildren()).basicAdd(otherEnd, msgs); | |
} | |
return super.eInverseAdd(otherEnd, featureID, msgs); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public NotificationChain eInverseRemove(InternalEObject otherEnd, | |
int featureID, NotificationChain msgs) { | |
switch (featureID) { | |
case ExtensionPackage.CODE_UNIT2_FILE__CHILDREN: | |
return ((InternalEList<?>)getChildren()).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 ExtensionPackage.CODE_UNIT2_FILE__FILE: | |
if (resolve) return getFile(); | |
return basicGetFile(); | |
case ExtensionPackage.CODE_UNIT2_FILE__CHILDREN: | |
return getChildren(); | |
case ExtensionPackage.CODE_UNIT2_FILE__UNIT: | |
if (resolve) return getUnit(); | |
return basicGetUnit(); | |
} | |
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 ExtensionPackage.CODE_UNIT2_FILE__FILE: | |
setFile((SourceFile)newValue); | |
return; | |
case ExtensionPackage.CODE_UNIT2_FILE__CHILDREN: | |
getChildren().clear(); | |
getChildren().addAll((Collection<? extends ASTNodeSourceRegion>)newValue); | |
return; | |
case ExtensionPackage.CODE_UNIT2_FILE__UNIT: | |
setUnit((EObject)newValue); | |
return; | |
} | |
super.eSet(featureID, newValue); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public void eUnset(int featureID) { | |
switch (featureID) { | |
case ExtensionPackage.CODE_UNIT2_FILE__FILE: | |
setFile((SourceFile)null); | |
return; | |
case ExtensionPackage.CODE_UNIT2_FILE__CHILDREN: | |
getChildren().clear(); | |
return; | |
case ExtensionPackage.CODE_UNIT2_FILE__UNIT: | |
setUnit((EObject)null); | |
return; | |
} | |
super.eUnset(featureID); | |
} | |
/** | |
* <!-- begin-user-doc --> <!-- end-user-doc --> | |
* @generated | |
*/ | |
@Override | |
public boolean eIsSet(int featureID) { | |
switch (featureID) { | |
case ExtensionPackage.CODE_UNIT2_FILE__FILE: | |
return file != null; | |
case ExtensionPackage.CODE_UNIT2_FILE__CHILDREN: | |
return children != null && !children.isEmpty(); | |
case ExtensionPackage.CODE_UNIT2_FILE__UNIT: | |
return unit != null; | |
} | |
return super.eIsSet(featureID); | |
} | |
} // CodeUnit2FileImpl |