/**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.obeonetwork.pim.gen.bootstrap.model.bootstrap.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.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.obeonetwork.pim.gen.bootstrap.model.bootstrap.BootstrapPackage;
import org.obeonetwork.pim.gen.bootstrap.model.bootstrap.MainPage;
import org.obeonetwork.pim.gen.bootstrap.model.bootstrap.Page;
import org.obeonetwork.pim.gen.bootstrap.model.bootstrap.Site;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Site</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.obeonetwork.pim.gen.bootstrap.model.bootstrap.impl.SiteImpl#getPages <em>Pages</em>}</li>
* <li>{@link org.obeonetwork.pim.gen.bootstrap.model.bootstrap.impl.SiteImpl#getMainPage <em>Main Page</em>}</li>
* <li>{@link org.obeonetwork.pim.gen.bootstrap.model.bootstrap.impl.SiteImpl#getTitle <em>Title</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class SiteImpl extends EObjectImpl implements Site {
/**
* The cached value of the '{@link #getPages() <em>Pages</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPages()
* @generated
* @ordered
*/
protected EList<Page> pages;
/**
* The cached value of the '{@link #getMainPage() <em>Main Page</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMainPage()
* @generated
* @ordered
*/
protected MainPage mainPage;
/**
* The default value of the '{@link #getTitle() <em>Title</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTitle()
* @generated
* @ordered
*/
protected static final String TITLE_EDEFAULT = null;
/**
* The cached value of the '{@link #getTitle() <em>Title</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTitle()
* @generated
* @ordered
*/
protected String title = TITLE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected SiteImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return BootstrapPackage.Literals.SITE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Page> getPages() {
if (pages == null) {
pages = new EObjectContainmentWithInverseEList<Page>(Page.class, this, BootstrapPackage.SITE__PAGES, BootstrapPackage.PAGE__SITE);
}
return pages;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public MainPage getMainPage() {
return mainPage;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetMainPage(MainPage newMainPage, NotificationChain msgs) {
MainPage oldMainPage = mainPage;
mainPage = newMainPage;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, BootstrapPackage.SITE__MAIN_PAGE, oldMainPage, newMainPage);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMainPage(MainPage newMainPage) {
if (newMainPage != mainPage) {
NotificationChain msgs = null;
if (mainPage != null)
msgs = ((InternalEObject)mainPage).eInverseRemove(this, BootstrapPackage.MAIN_PAGE__SITE, MainPage.class, msgs);
if (newMainPage != null)
msgs = ((InternalEObject)newMainPage).eInverseAdd(this, BootstrapPackage.MAIN_PAGE__SITE, MainPage.class, msgs);
msgs = basicSetMainPage(newMainPage, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BootstrapPackage.SITE__MAIN_PAGE, newMainPage, newMainPage));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getTitle() {
return title;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTitle(String newTitle) {
String oldTitle = title;
title = newTitle;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, BootstrapPackage.SITE__TITLE, oldTitle, title));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case BootstrapPackage.SITE__PAGES:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getPages()).basicAdd(otherEnd, msgs);
case BootstrapPackage.SITE__MAIN_PAGE:
if (mainPage != null)
msgs = ((InternalEObject)mainPage).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - BootstrapPackage.SITE__MAIN_PAGE, null, msgs);
return basicSetMainPage((MainPage)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 BootstrapPackage.SITE__PAGES:
return ((InternalEList<?>)getPages()).basicRemove(otherEnd, msgs);
case BootstrapPackage.SITE__MAIN_PAGE:
return basicSetMainPage(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 BootstrapPackage.SITE__PAGES:
return getPages();
case BootstrapPackage.SITE__MAIN_PAGE:
return getMainPage();
case BootstrapPackage.SITE__TITLE:
return getTitle();
}
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 BootstrapPackage.SITE__PAGES:
getPages().clear();
getPages().addAll((Collection<? extends Page>)newValue);
return;
case BootstrapPackage.SITE__MAIN_PAGE:
setMainPage((MainPage)newValue);
return;
case BootstrapPackage.SITE__TITLE:
setTitle((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case BootstrapPackage.SITE__PAGES:
getPages().clear();
return;
case BootstrapPackage.SITE__MAIN_PAGE:
setMainPage((MainPage)null);
return;
case BootstrapPackage.SITE__TITLE:
setTitle(TITLE_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case BootstrapPackage.SITE__PAGES:
return pages != null && !pages.isEmpty();
case BootstrapPackage.SITE__MAIN_PAGE:
return mainPage != null;
case BootstrapPackage.SITE__TITLE:
return TITLE_EDEFAULT == null ? title != null : !TITLE_EDEFAULT.equals(title);
}
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(" (title: "); //$NON-NLS-1$
result.append(title);
result.append(')');
return result.toString();
}
} //SiteImpl