/** * <copyright> * </copyright> * * $Id: BookImpl.java,v 1.2 2007/02/22 21:48:18 ahunter Exp $ */ package org.eclipse.gmf.examples.eclipsecon.library.impl; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; 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.gmf.examples.eclipsecon.library.Author; import org.eclipse.gmf.examples.eclipsecon.library.Book; import org.eclipse.gmf.examples.eclipsecon.library.LibraryPackage; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Book</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.eclipse.gmf.examples.eclipsecon.library.impl.BookImpl#getTitle <em>Title</em>}</li> * <li>{@link org.eclipse.gmf.examples.eclipsecon.library.impl.BookImpl#getAuthor <em>Author</em>}</li> * </ul> * </p> * * @generated */ public class BookImpl extends EObjectImpl implements Book { /** * 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; /** * The cached value of the '{@link #getAuthor() <em>Author</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getAuthor() * @generated * @ordered */ protected Author author = null; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected BookImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected EClass eStaticClass() { return LibraryPackage.Literals.BOOK; } /** * <!-- 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, LibraryPackage.BOOK__TITLE, oldTitle, title)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Author getAuthor() { if (author != null && author.eIsProxy()) { InternalEObject oldAuthor = (InternalEObject)author; author = (Author)eResolveProxy(oldAuthor); if (author != oldAuthor) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, LibraryPackage.BOOK__AUTHOR, oldAuthor, author)); } } return author; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Author basicGetAuthor() { return author; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetAuthor(Author newAuthor, NotificationChain msgs) { Author oldAuthor = author; author = newAuthor; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, LibraryPackage.BOOK__AUTHOR, oldAuthor, newAuthor); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setAuthor(Author newAuthor) { if (newAuthor != author) { NotificationChain msgs = null; if (author != null) msgs = ((InternalEObject)author).eInverseRemove(this, LibraryPackage.AUTHOR__BOOKS, Author.class, msgs); if (newAuthor != null) msgs = ((InternalEObject)newAuthor).eInverseAdd(this, LibraryPackage.AUTHOR__BOOKS, Author.class, msgs); msgs = basicSetAuthor(newAuthor, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, LibraryPackage.BOOK__AUTHOR, newAuthor, newAuthor)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case LibraryPackage.BOOK__AUTHOR: if (author != null) msgs = ((InternalEObject)author).eInverseRemove(this, LibraryPackage.AUTHOR__BOOKS, Author.class, msgs); return basicSetAuthor((Author)otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case LibraryPackage.BOOK__AUTHOR: return basicSetAuthor(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case LibraryPackage.BOOK__TITLE: return getTitle(); case LibraryPackage.BOOK__AUTHOR: if (resolve) return getAuthor(); return basicGetAuthor(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void eSet(int featureID, Object newValue) { switch (featureID) { case LibraryPackage.BOOK__TITLE: setTitle((String)newValue); return; case LibraryPackage.BOOK__AUTHOR: setAuthor((Author)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void eUnset(int featureID) { switch (featureID) { case LibraryPackage.BOOK__TITLE: setTitle(TITLE_EDEFAULT); return; case LibraryPackage.BOOK__AUTHOR: setAuthor((Author)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public boolean eIsSet(int featureID) { switch (featureID) { case LibraryPackage.BOOK__TITLE: return TITLE_EDEFAULT == null ? title != null : !TITLE_EDEFAULT.equals(title); case LibraryPackage.BOOK__AUTHOR: return author != null; } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (title: "); result.append(title); result.append(')'); return result.toString(); } } //BookImpl