blob: bef5457d74c07b7a66649aea214ed7b07ded5835 [file] [log] [blame]
/**
* <copyright>
* Copyright (c) 2008, 2018 Open Canarias S.L. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* A. Sanchez-Barbudo - initial API and implementation
* </copyright>
*
* $Id: UnpackExpImpl.java,v 1.3 2009/02/06 15:47:30 radvorak Exp $
*/
package org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.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.util.EObjectResolvingEList;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.ImperativeOCLPackage;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.UnpackExp;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.util.ImperativeOCLVisitor;
import org.eclipse.ocl.ecore.OCLExpression;
import org.eclipse.ocl.ecore.Variable;
import org.eclipse.ocl.utilities.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Unpack Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.UnpackExpImpl#getSource <em>Source</em>}</li>
* <li>{@link org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.impl.UnpackExpImpl#getTargetVariable <em>Target Variable</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class UnpackExpImpl extends ImperativeExpressionImpl implements UnpackExp {
/**
* The cached value of the '{@link #getSource() <em>Source</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSource()
* @generated
* @ordered
*/
protected OCLExpression source;
/**
* The cached value of the '{@link #getTargetVariable() <em>Target Variable</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTargetVariable()
* @generated
* @ordered
*/
protected EList<Variable> targetVariable;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected UnpackExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return ImperativeOCLPackage.Literals.UNPACK_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OCLExpression getSource() {
return source;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetSource(OCLExpression newSource, NotificationChain msgs) {
OCLExpression oldSource = source;
source = newSource;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.UNPACK_EXP__SOURCE, oldSource, newSource);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setSource(OCLExpression newSource) {
if (newSource != source) {
NotificationChain msgs = null;
if (source != null)
msgs = ((InternalEObject)source).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.UNPACK_EXP__SOURCE, null, msgs);
if (newSource != null)
msgs = ((InternalEObject)newSource).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ImperativeOCLPackage.UNPACK_EXP__SOURCE, null, msgs);
msgs = basicSetSource(newSource, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, ImperativeOCLPackage.UNPACK_EXP__SOURCE, newSource, newSource));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Variable> getTargetVariable() {
if (targetVariable == null) {
targetVariable = new EObjectResolvingEList<Variable>(Variable.class, this, ImperativeOCLPackage.UNPACK_EXP__TARGET_VARIABLE);
}
return targetVariable;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case ImperativeOCLPackage.UNPACK_EXP__SOURCE:
return basicSetSource(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 ImperativeOCLPackage.UNPACK_EXP__SOURCE:
return getSource();
case ImperativeOCLPackage.UNPACK_EXP__TARGET_VARIABLE:
return getTargetVariable();
}
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 ImperativeOCLPackage.UNPACK_EXP__SOURCE:
setSource((OCLExpression)newValue);
return;
case ImperativeOCLPackage.UNPACK_EXP__TARGET_VARIABLE:
getTargetVariable().clear();
getTargetVariable().addAll((Collection<? extends Variable>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case ImperativeOCLPackage.UNPACK_EXP__SOURCE:
setSource((OCLExpression)null);
return;
case ImperativeOCLPackage.UNPACK_EXP__TARGET_VARIABLE:
getTargetVariable().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case ImperativeOCLPackage.UNPACK_EXP__SOURCE:
return source != null;
case ImperativeOCLPackage.UNPACK_EXP__TARGET_VARIABLE:
return targetVariable != null && !targetVariable.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* @generated NOT
*/
@SuppressWarnings("unchecked")
@Override
public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) {
if (v instanceof ImperativeOCLVisitor)
return (T) ((ImperativeOCLVisitor) v).visitUnpackExp(this);
return super.<T, U>accept(v);
}
} //UnpackExpImpl