/**
*/
package org.xtext.builddsl.build.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.xtype.XImportSection;
import org.xtext.builddsl.build.BuildFile;
import org.xtext.builddsl.build.BuildPackage;
import org.xtext.builddsl.build.Declaration;
/**
* <!-- 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.builddsl.build.impl.BuildFileImpl#getName <em>Name</em>}</li>
* <li>{@link org.xtext.builddsl.build.impl.BuildFileImpl#getImportSection <em>Import Section</em>}</li>
* <li>{@link org.xtext.builddsl.build.impl.BuildFileImpl#getDeclarations <em>Declarations</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class BuildFileImpl extends MinimalEObjectImpl.Container implements BuildFile
{
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected static final String NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getName()
* @generated
* @ordered
*/
protected String name = NAME_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 #getDeclarations() <em>Declarations</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDeclarations()
* @generated
* @ordered
*/
protected EList<Declaration> declarations;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected BuildFileImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return BuildPackage.Literals.BUILD_FILE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getName()
{
return name;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setName(String newName)
{
String oldName = name;
name = newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BuildPackage.BUILD_FILE__NAME, oldName, name));
}
/**
* <!-- 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, BuildPackage.BUILD_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 - BuildPackage.BUILD_FILE__IMPORT_SECTION, null, msgs);
if (newImportSection != null)
msgs = ((InternalEObject)newImportSection).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - BuildPackage.BUILD_FILE__IMPORT_SECTION, null, msgs);
msgs = basicSetImportSection(newImportSection, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BuildPackage.BUILD_FILE__IMPORT_SECTION, newImportSection, newImportSection));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Declaration> getDeclarations()
{
if (declarations == null)
{
declarations = new EObjectContainmentEList<Declaration>(Declaration.class, this, BuildPackage.BUILD_FILE__DECLARATIONS);
}
return declarations;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case BuildPackage.BUILD_FILE__IMPORT_SECTION:
return basicSetImportSection(null, msgs);
case BuildPackage.BUILD_FILE__DECLARATIONS:
return ((InternalEList<?>)getDeclarations()).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 BuildPackage.BUILD_FILE__NAME:
return getName();
case BuildPackage.BUILD_FILE__IMPORT_SECTION:
return getImportSection();
case BuildPackage.BUILD_FILE__DECLARATIONS:
return getDeclarations();
}
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 BuildPackage.BUILD_FILE__NAME:
setName((String)newValue);
return;
case BuildPackage.BUILD_FILE__IMPORT_SECTION:
setImportSection((XImportSection)newValue);
return;
case BuildPackage.BUILD_FILE__DECLARATIONS:
getDeclarations().clear();
getDeclarations().addAll((Collection<? extends Declaration>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case BuildPackage.BUILD_FILE__NAME:
setName(NAME_EDEFAULT);
return;
case BuildPackage.BUILD_FILE__IMPORT_SECTION:
setImportSection((XImportSection)null);
return;
case BuildPackage.BUILD_FILE__DECLARATIONS:
getDeclarations().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case BuildPackage.BUILD_FILE__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case BuildPackage.BUILD_FILE__IMPORT_SECTION:
return importSection != null;
case BuildPackage.BUILD_FILE__DECLARATIONS:
return declarations != null && !declarations.isEmpty();
}
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(" (name: ");
result.append(name);
result.append(')');
return result.toString();
}
} //BuildFileImpl