/*
* ModifyImpl.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.Goal;
import eu.aniketos.wp1.ststool.Modify;
import eu.aniketos.wp1.ststool.StstoolPackage;
import eu.aniketos.wp1.ststool.TResource;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>Modify</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link eu.aniketos.wp1.ststool.impl.ModifyImpl#getSource <em>Source</em>}</li>
* <li>{@link eu.aniketos.wp1.ststool.impl.ModifyImpl#getTarget <em>Target</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ModifyImpl extends StsRelationImpl implements Modify {
/**
* <!-- 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 TResource target;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected ModifyImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass(){
return StstoolPackage.Literals.MODIFY;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public Goal getSource(){
if (eContainerFeatureID() != StstoolPackage.MODIFY__SOURCE) return null;
return (Goal)eContainer();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetSource(Goal newSource,NotificationChain msgs){
msgs = eBasicSetContainer((InternalEObject)newSource, StstoolPackage.MODIFY__SOURCE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setSource(Goal newSource){
if (newSource != eInternalContainer() || (eContainerFeatureID() != StstoolPackage.MODIFY__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.GOAL__RESOURCES_MODIFIED, Goal.class, msgs);
msgs = basicSetSource(newSource, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StstoolPackage.MODIFY__SOURCE, newSource, newSource));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public TResource getTarget(){
if (target != null && target.eIsProxy()) {
InternalEObject oldTarget = (InternalEObject)target;
target = (TResource)eResolveProxy(oldTarget);
if (target != oldTarget) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, StstoolPackage.MODIFY__TARGET, oldTarget, target));
}
}
return target;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public TResource basicGetTarget(){
return target;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTarget(TResource newTarget,NotificationChain msgs){
TResource oldTarget = target;
target = newTarget;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StstoolPackage.MODIFY__TARGET, oldTarget, newTarget);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setTarget(TResource newTarget){
if (newTarget != target) {
NotificationChain msgs = null;
if (target != null)
msgs = ((InternalEObject)target).eInverseRemove(this, StstoolPackage.TRESOURCE__GOALS_MODIFING, TResource.class, msgs);
if (newTarget != null)
msgs = ((InternalEObject)newTarget).eInverseAdd(this, StstoolPackage.TRESOURCE__GOALS_MODIFING, TResource.class, msgs);
msgs = basicSetTarget(newTarget, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StstoolPackage.MODIFY__TARGET, newTarget, newTarget));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd,int featureID,NotificationChain msgs){
switch (featureID) {
case StstoolPackage.MODIFY__SOURCE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetSource((Goal)otherEnd, msgs);
case StstoolPackage.MODIFY__TARGET:
if (target != null)
msgs = ((InternalEObject)target).eInverseRemove(this, StstoolPackage.TRESOURCE__GOALS_MODIFING, TResource.class, msgs);
return basicSetTarget((TResource)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.MODIFY__SOURCE:
return basicSetSource(null, msgs);
case StstoolPackage.MODIFY__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.MODIFY__SOURCE:
return eInternalContainer().eInverseRemove(this, StstoolPackage.GOAL__RESOURCES_MODIFIED, Goal.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.MODIFY__SOURCE:
return getSource();
case StstoolPackage.MODIFY__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.MODIFY__SOURCE:
setSource((Goal)newValue);
return;
case StstoolPackage.MODIFY__TARGET:
setTarget((TResource)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID){
switch (featureID) {
case StstoolPackage.MODIFY__SOURCE:
setSource((Goal)null);
return;
case StstoolPackage.MODIFY__TARGET:
setTarget((TResource)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID){
switch (featureID) {
case StstoolPackage.MODIFY__SOURCE:
return getSource() != null;
case StstoolPackage.MODIFY__TARGET:
return target != null;
}
return super.eIsSet(featureID);
}
} //ModifyImpl