blob: 0cd5f9867e34d6a92486e3c564c6e0f40cd5bf8a [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008, 2012 Obeo.
* 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:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.acceleo.compatibility.model.mt.core.impl;
import java.util.Collection;
import org.eclipse.acceleo.compatibility.model.mt.core.CorePackage;
import org.eclipse.acceleo.compatibility.model.mt.core.Script;
import org.eclipse.acceleo.compatibility.model.mt.core.ScriptDescriptor;
import org.eclipse.acceleo.compatibility.model.mt.statements.Statement;
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;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Script</b></em>'. <!-- end-user-doc
* -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.acceleo.compatibility.model.mt.core.impl.ScriptImpl#getDescriptor <em>Descriptor
* </em>}</li>
* <li>{@link org.eclipse.acceleo.compatibility.model.mt.core.impl.ScriptImpl#getStatements <em>Statements
* </em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ScriptImpl extends ASTNodeImpl implements Script {
/**
* The cached value of the '{@link #getDescriptor() <em>Descriptor</em>}' containment reference. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getDescriptor()
* @generated
* @ordered
*/
protected ScriptDescriptor descriptor;
/**
* The cached value of the '{@link #getStatements() <em>Statements</em>}' containment reference list. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @see #getStatements()
* @generated
* @ordered
*/
protected EList<Statement> statements;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected ScriptImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return CorePackage.Literals.SCRIPT;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public ScriptDescriptor getDescriptor() {
return descriptor;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetDescriptor(ScriptDescriptor newDescriptor, NotificationChain msgs) {
ScriptDescriptor oldDescriptor = descriptor;
descriptor = newDescriptor;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
CorePackage.SCRIPT__DESCRIPTOR, oldDescriptor, newDescriptor);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setDescriptor(ScriptDescriptor newDescriptor) {
if (newDescriptor != descriptor) {
NotificationChain msgs = null;
if (descriptor != null)
msgs = ((InternalEObject)descriptor).eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- CorePackage.SCRIPT__DESCRIPTOR, null, msgs);
if (newDescriptor != null)
msgs = ((InternalEObject)newDescriptor).eInverseAdd(this, EOPPOSITE_FEATURE_BASE
- CorePackage.SCRIPT__DESCRIPTOR, null, msgs);
msgs = basicSetDescriptor(newDescriptor, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CorePackage.SCRIPT__DESCRIPTOR,
newDescriptor, newDescriptor));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public EList<Statement> getStatements() {
if (statements == null) {
statements = new EObjectContainmentEList<Statement>(Statement.class, this,
CorePackage.SCRIPT__STATEMENTS);
}
return statements;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CorePackage.SCRIPT__DESCRIPTOR:
return basicSetDescriptor(null, msgs);
case CorePackage.SCRIPT__STATEMENTS:
return ((InternalEList<?>)getStatements()).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 CorePackage.SCRIPT__DESCRIPTOR:
return getDescriptor();
case CorePackage.SCRIPT__STATEMENTS:
return getStatements();
}
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.SCRIPT__DESCRIPTOR:
setDescriptor((ScriptDescriptor)newValue);
return;
case CorePackage.SCRIPT__STATEMENTS:
getStatements().clear();
getStatements().addAll((Collection<? extends Statement>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CorePackage.SCRIPT__DESCRIPTOR:
setDescriptor((ScriptDescriptor)null);
return;
case CorePackage.SCRIPT__STATEMENTS:
getStatements().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CorePackage.SCRIPT__DESCRIPTOR:
return descriptor != null;
case CorePackage.SCRIPT__STATEMENTS:
return statements != null && !statements.isEmpty();
}
return super.eIsSet(featureID);
}
} // ScriptImpl