/**
*/
package org.xtext.template.template.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.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.xtext.xbase.XBlockExpression;
import org.eclipse.xtext.xtype.XImportSection;
import org.xtext.template.template.Parameter;
import org.xtext.template.template.TemplateFile;
import org.xtext.template.template.TemplatePackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>File</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.xtext.template.template.impl.TemplateFileImpl#getPackage <em>Package</em>}</li>
* <li>{@link org.xtext.template.template.impl.TemplateFileImpl#getImportSection <em>Import Section</em>}</li>
* <li>{@link org.xtext.template.template.impl.TemplateFileImpl#getParams <em>Params</em>}</li>
* <li>{@link org.xtext.template.template.impl.TemplateFileImpl#getBody <em>Body</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class TemplateFileImpl extends MinimalEObjectImpl.Container implements TemplateFile
{
/**
* The default value of the '{@link #getPackage() <em>Package</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPackage()
* @generated
* @ordered
*/
protected static final String PACKAGE_EDEFAULT = null;
/**
* The cached value of the '{@link #getPackage() <em>Package</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPackage()
* @generated
* @ordered
*/
protected String package_ = PACKAGE_EDEFAULT;
/**
* The cached value of the '{@link #getImportSection() <em>Import Section</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getImportSection()
* @generated
* @ordered
*/
protected XImportSection importSection;
/**
* The cached value of the '{@link #getParams() <em>Params</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParams()
* @generated
* @ordered
*/
protected EList<Parameter> params;
/**
* The cached value of the '{@link #getBody() <em>Body</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getBody()
* @generated
* @ordered
*/
protected XBlockExpression body;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TemplateFileImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return TemplatePackage.Literals.TEMPLATE_FILE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getPackage()
{
return package_;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPackage(String newPackage)
{
String oldPackage = package_;
package_ = newPackage;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TemplatePackage.TEMPLATE_FILE__PACKAGE, oldPackage, package_));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public XImportSection getImportSection()
{
return importSection;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetImportSection(XImportSection newImportSection, NotificationChain msgs)
{
XImportSection oldImportSection = importSection;
importSection = newImportSection;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION, oldImportSection, newImportSection);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setImportSection(XImportSection newImportSection)
{
if (newImportSection != importSection)
{
NotificationChain msgs = null;
if (importSection != null)
msgs = ((InternalEObject)importSection).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION, null, msgs);
if (newImportSection != null)
msgs = ((InternalEObject)newImportSection).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION, null, msgs);
msgs = basicSetImportSection(newImportSection, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION, newImportSection, newImportSection));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Parameter> getParams()
{
if (params == null)
{
params = new EObjectContainmentEList<Parameter>(Parameter.class, this, TemplatePackage.TEMPLATE_FILE__PARAMS);
}
return params;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public XBlockExpression getBody()
{
return body;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBody(XBlockExpression newBody, NotificationChain msgs)
{
XBlockExpression oldBody = body;
body = newBody;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TemplatePackage.TEMPLATE_FILE__BODY, oldBody, newBody);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBody(XBlockExpression newBody)
{
if (newBody != body)
{
NotificationChain msgs = null;
if (body != null)
msgs = ((InternalEObject)body).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - TemplatePackage.TEMPLATE_FILE__BODY, null, msgs);
if (newBody != null)
msgs = ((InternalEObject)newBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - TemplatePackage.TEMPLATE_FILE__BODY, null, msgs);
msgs = basicSetBody(newBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TemplatePackage.TEMPLATE_FILE__BODY, newBody, newBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION:
return basicSetImportSection(null, msgs);
case TemplatePackage.TEMPLATE_FILE__PARAMS:
return ((InternalEList<?>)getParams()).basicRemove(otherEnd, msgs);
case TemplatePackage.TEMPLATE_FILE__BODY:
return basicSetBody(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 TemplatePackage.TEMPLATE_FILE__PACKAGE:
return getPackage();
case TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION:
return getImportSection();
case TemplatePackage.TEMPLATE_FILE__PARAMS:
return getParams();
case TemplatePackage.TEMPLATE_FILE__BODY:
return getBody();
}
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 TemplatePackage.TEMPLATE_FILE__PACKAGE:
setPackage((String)newValue);
return;
case TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION:
setImportSection((XImportSection)newValue);
return;
case TemplatePackage.TEMPLATE_FILE__PARAMS:
getParams().clear();
getParams().addAll((Collection<? extends Parameter>)newValue);
return;
case TemplatePackage.TEMPLATE_FILE__BODY:
setBody((XBlockExpression)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case TemplatePackage.TEMPLATE_FILE__PACKAGE:
setPackage(PACKAGE_EDEFAULT);
return;
case TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION:
setImportSection((XImportSection)null);
return;
case TemplatePackage.TEMPLATE_FILE__PARAMS:
getParams().clear();
return;
case TemplatePackage.TEMPLATE_FILE__BODY:
setBody((XBlockExpression)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case TemplatePackage.TEMPLATE_FILE__PACKAGE:
return PACKAGE_EDEFAULT == null ? package_ != null : !PACKAGE_EDEFAULT.equals(package_);
case TemplatePackage.TEMPLATE_FILE__IMPORT_SECTION:
return importSection != null;
case TemplatePackage.TEMPLATE_FILE__PARAMS:
return params != null && !params.isEmpty();
case TemplatePackage.TEMPLATE_FILE__BODY:
return body != null;
}
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(" (package: ");
result.append(package_);
result.append(')');
return result.toString();
}
} //TemplateFileImpl