/* license-start * * Copyright (C) 2008 - 2013 Crispico, <http://www.crispico.com/>. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details, at <http://www.gnu.org/licenses/>. * * Contributors: * Crispico - Initial API and implementation * * license-end */ /** * <copyright> * </copyright> * * $Id$ */ package org.flowerplatform.web.entity.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.flowerplatform.web.entity.EntityPackage; import org.flowerplatform.web.entity.FavoriteItem; import org.flowerplatform.web.entity.Organization; import org.flowerplatform.web.entity.RecentResource; import org.flowerplatform.web.entity.User; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Favorite Item</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.flowerplatform.web.entity.impl.FavoriteItemImpl#getUser <em>User</em>}</li> * <li>{@link org.flowerplatform.web.entity.impl.FavoriteItemImpl#getResource <em>Resource</em>}</li> * <li>{@link org.flowerplatform.web.entity.impl.FavoriteItemImpl#getOrganization <em>Organization</em>}</li> * <li>{@link org.flowerplatform.web.entity.impl.FavoriteItemImpl#getCategory <em>Category</em>}</li> * </ul> * </p> * * @generated */ public class FavoriteItemImpl extends EntityImpl implements FavoriteItem { /** * The cached value of the '{@link #getUser() <em>User</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getUser() * @generated * @ordered */ protected User user; /** * The cached value of the '{@link #getResource() <em>Resource</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getResource() * @generated * @ordered */ protected RecentResource resource; /** * The cached value of the '{@link #getOrganization() <em>Organization</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOrganization() * @generated * @ordered */ protected Organization organization; /** * The default value of the '{@link #getCategory() <em>Category</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCategory() * @generated * @ordered */ protected static final int CATEGORY_EDEFAULT = 0; /** * The cached value of the '{@link #getCategory() <em>Category</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getCategory() * @generated * @ordered */ protected int category = CATEGORY_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected FavoriteItemImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return EntityPackage.Literals.FAVORITE_ITEM; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public User getUser() { if (user != null && user.eIsProxy()) { InternalEObject oldUser = (InternalEObject)user; user = (User)eResolveProxy(oldUser); if (user != oldUser) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityPackage.FAVORITE_ITEM__USER, oldUser, user)); } } return user; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public User basicGetUser() { return user; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetUser(User newUser, NotificationChain msgs) { User oldUser = user; user = newUser; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EntityPackage.FAVORITE_ITEM__USER, oldUser, newUser); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setUser(User newUser) { if (newUser != user) { NotificationChain msgs = null; if (user != null) msgs = ((InternalEObject)user).eInverseRemove(this, EntityPackage.USER__FAVORITE_ITEMS, User.class, msgs); if (newUser != null) msgs = ((InternalEObject)newUser).eInverseAdd(this, EntityPackage.USER__FAVORITE_ITEMS, User.class, msgs); msgs = basicSetUser(newUser, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EntityPackage.FAVORITE_ITEM__USER, newUser, newUser)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public RecentResource getResource() { if (resource != null && resource.eIsProxy()) { InternalEObject oldResource = (InternalEObject)resource; resource = (RecentResource)eResolveProxy(oldResource); if (resource != oldResource) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityPackage.FAVORITE_ITEM__RESOURCE, oldResource, resource)); } } return resource; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public RecentResource basicGetResource() { return resource; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setResource(RecentResource newResource) { RecentResource oldResource = resource; resource = newResource; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EntityPackage.FAVORITE_ITEM__RESOURCE, oldResource, resource)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Organization getOrganization() { if (organization != null && organization.eIsProxy()) { InternalEObject oldOrganization = (InternalEObject)organization; organization = (Organization)eResolveProxy(oldOrganization); if (organization != oldOrganization) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, EntityPackage.FAVORITE_ITEM__ORGANIZATION, oldOrganization, organization)); } } return organization; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Organization basicGetOrganization() { return organization; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setOrganization(Organization newOrganization) { Organization oldOrganization = organization; organization = newOrganization; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EntityPackage.FAVORITE_ITEM__ORGANIZATION, oldOrganization, organization)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public int getCategory() { return category; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setCategory(int newCategory) { int oldCategory = category; category = newCategory; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EntityPackage.FAVORITE_ITEM__CATEGORY, oldCategory, category)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT * @author Mariana */ public Object getItem() { if (getResource() != null) { return getResource(); } return getOrganization(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT * @author Mariana */ public void setItem(Object item) { if (item instanceof RecentResource) { setResource((RecentResource) item); } else { if (item instanceof Organization) { setOrganization((Organization) item); } } } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case EntityPackage.FAVORITE_ITEM__USER: if (user != null) msgs = ((InternalEObject)user).eInverseRemove(this, EntityPackage.USER__FAVORITE_ITEMS, User.class, msgs); return basicSetUser((User)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 EntityPackage.FAVORITE_ITEM__USER: return basicSetUser(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 EntityPackage.FAVORITE_ITEM__USER: if (resolve) return getUser(); return basicGetUser(); case EntityPackage.FAVORITE_ITEM__RESOURCE: if (resolve) return getResource(); return basicGetResource(); case EntityPackage.FAVORITE_ITEM__ORGANIZATION: if (resolve) return getOrganization(); return basicGetOrganization(); case EntityPackage.FAVORITE_ITEM__CATEGORY: return getCategory(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case EntityPackage.FAVORITE_ITEM__USER: setUser((User)newValue); return; case EntityPackage.FAVORITE_ITEM__RESOURCE: setResource((RecentResource)newValue); return; case EntityPackage.FAVORITE_ITEM__ORGANIZATION: setOrganization((Organization)newValue); return; case EntityPackage.FAVORITE_ITEM__CATEGORY: setCategory((Integer)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case EntityPackage.FAVORITE_ITEM__USER: setUser((User)null); return; case EntityPackage.FAVORITE_ITEM__RESOURCE: setResource((RecentResource)null); return; case EntityPackage.FAVORITE_ITEM__ORGANIZATION: setOrganization((Organization)null); return; case EntityPackage.FAVORITE_ITEM__CATEGORY: setCategory(CATEGORY_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case EntityPackage.FAVORITE_ITEM__USER: return user != null; case EntityPackage.FAVORITE_ITEM__RESOURCE: return resource != null; case EntityPackage.FAVORITE_ITEM__ORGANIZATION: return organization != null; case EntityPackage.FAVORITE_ITEM__CATEGORY: return category != CATEGORY_EDEFAULT; } 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(" (category: "); result.append(category); result.append(')'); return result.toString(); } } //FavoriteItemImpl