/* * PlayImpl.java * * This file is part of the STS-Tool project. * Copyright (c) 2011-2012 "University of Trento - DISI" All rights reserved. * * Is strictly forbidden to remove this copyright notice from this source code. * * Disclaimer of Warranty: * STS-Tool (this software) is provided "as-is" and without warranty of any kind, * express, implied or otherwise, including without limitation, any warranty of * merchantability or fitness for a particular purpose. * In no event shall the copyright holder or contributors be liable for any direct, * indirect, incidental, special, exemplary, or consequential damages * including, but not limited to, procurement of substitute goods or services; * loss of use, data, or profits; or business interruption) however caused and on * any theory of liability, whether in contract, strict liability, or tort (including * negligence or otherwise) arising in any way out of the use of this software, even * if advised of the possibility of such damage. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License version 3 * as published by the Free Software Foundation with the addition of the * following permission added to Section 15 as permitted in Section 7(a): * FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY * "University of Trento - DISI","University of Trento - DISI" DISCLAIMS THE * WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. * * See the GNU Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public License * along with this program; if not, see http://www.gnu.org/licenses or write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA, 02110-1301 USA, or download the license from the following URL: * http://www.sts-tool.eu/License.php * * For more information, please contact STS-Tool group at this * address: ststool@disi.unitn.it * */ /** * DISI - University of Trento * * $Id$ */ package eu.aniketos.wp1.ststool.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.util.EcoreUtil; import eu.aniketos.wp1.ststool.Agent; import eu.aniketos.wp1.ststool.Play; import eu.aniketos.wp1.ststool.Role; import eu.aniketos.wp1.ststool.StstoolPackage; /** * <!-- begin-user-doc --> An implementation of the model object '<em><b>Play</b></em>'. <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link eu.aniketos.wp1.ststool.impl.PlayImpl#getSource <em>Source</em>}</li> * <li>{@link eu.aniketos.wp1.ststool.impl.PlayImpl#getTarget <em>Target</em>}</li> * </ul> * </p> * * @generated */ public class PlayImpl extends StsRelationImpl implements Play { /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public static final String copyright = "DISI - University of Trento"; /** * The cached value of the '{@link #getTarget() <em>Target</em>}' reference. * <!-- begin-user-doc --> <!-- end-user-doc --> * @see #getTarget() * @generated * @ordered */ protected Role target; /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ protected PlayImpl() { super(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass(){ return StstoolPackage.Literals.PLAY; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public Agent getSource(){ if (eContainerFeatureID() != StstoolPackage.PLAY__SOURCE) return null; return (Agent)eContainer(); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public NotificationChain basicSetSource(Agent newSource,NotificationChain msgs){ msgs = eBasicSetContainer((InternalEObject)newSource, StstoolPackage.PLAY__SOURCE, msgs); return msgs; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public void setSource(Agent newSource){ if (newSource != eInternalContainer() || (eContainerFeatureID() != StstoolPackage.PLAY__SOURCE && newSource != null)) { if (EcoreUtil.isAncestor(this, newSource)) throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); NotificationChain msgs = null; if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); if (newSource != null) msgs = ((InternalEObject)newSource).eInverseAdd(this, StstoolPackage.AGENT__PLAYED_ROLES, Agent.class, msgs); msgs = basicSetSource(newSource, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StstoolPackage.PLAY__SOURCE, newSource, newSource)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public Role getTarget(){ if (target != null && target.eIsProxy()) { InternalEObject oldTarget = (InternalEObject)target; target = (Role)eResolveProxy(oldTarget); if (target != oldTarget) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, StstoolPackage.PLAY__TARGET, oldTarget, target)); } } return target; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public Role basicGetTarget(){ return target; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public NotificationChain basicSetTarget(Role newTarget,NotificationChain msgs){ Role oldTarget = target; target = newTarget; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StstoolPackage.PLAY__TARGET, oldTarget, newTarget); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ public void setTarget(Role newTarget){ if (newTarget != target) { NotificationChain msgs = null; if (target != null) msgs = ((InternalEObject)target).eInverseRemove(this, StstoolPackage.ROLE__PLAYED_BY, Role.class, msgs); if (newTarget != null) msgs = ((InternalEObject)newTarget).eInverseAdd(this, StstoolPackage.ROLE__PLAYED_BY, Role.class, msgs); msgs = basicSetTarget(newTarget, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, StstoolPackage.PLAY__TARGET, newTarget, newTarget)); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd,int featureID,NotificationChain msgs){ switch (featureID) { case StstoolPackage.PLAY__SOURCE: if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs); return basicSetSource((Agent)otherEnd, msgs); case StstoolPackage.PLAY__TARGET: if (target != null) msgs = ((InternalEObject)target).eInverseRemove(this, StstoolPackage.ROLE__PLAYED_BY, Role.class, msgs); return basicSetTarget((Role)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 StstoolPackage.PLAY__SOURCE: return basicSetSource(null, msgs); case StstoolPackage.PLAY__TARGET: return basicSetTarget(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs){ switch (eContainerFeatureID()) { case StstoolPackage.PLAY__SOURCE: return eInternalContainer().eInverseRemove(this, StstoolPackage.AGENT__PLAYED_ROLES, Agent.class, msgs); } return super.eBasicRemoveFromContainerFeature(msgs); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID,boolean resolve,boolean coreType){ switch (featureID) { case StstoolPackage.PLAY__SOURCE: return getSource(); case StstoolPackage.PLAY__TARGET: if (resolve) return getTarget(); return basicGetTarget(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID,Object newValue){ switch (featureID) { case StstoolPackage.PLAY__SOURCE: setSource((Agent)newValue); return; case StstoolPackage.PLAY__TARGET: setTarget((Role)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID){ switch (featureID) { case StstoolPackage.PLAY__SOURCE: setSource((Agent)null); return; case StstoolPackage.PLAY__TARGET: setTarget((Role)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID){ switch (featureID) { case StstoolPackage.PLAY__SOURCE: return getSource() != null; case StstoolPackage.PLAY__TARGET: return target != null; } return super.eIsSet(featureID); } } //PlayImpl