blob: d8036f51e14025b9976d082d36e1d10630208ec5 [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2007, 2008 E.D.Willink and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* E.D.Willink - initial API and implementation
*
* </copyright>
*
* $Id: AssignmentImpl.java,v 1.2 2009/11/19 10:33:46 ewillink Exp $
*/
package org.eclipse.qvt.declarative.emof.QVTCore.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 org.eclipse.qvt.declarative.emof.EMOF.impl.ElementImpl;
import org.eclipse.qvt.declarative.emof.EssentialOCL.OclExpression;
import org.eclipse.qvt.declarative.emof.QVTCore.Assignment;
import org.eclipse.qvt.declarative.emof.QVTCore.BottomPattern;
import org.eclipse.qvt.declarative.emof.QVTCore.QVTCorePackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Assignment</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.qvt.declarative.emof.QVTCore.impl.AssignmentImpl#getBottomPattern <em>Bottom Pattern</em>}</li>
* <li>{@link org.eclipse.qvt.declarative.emof.QVTCore.impl.AssignmentImpl#getIsDefault <em>Is Default</em>}</li>
* <li>{@link org.eclipse.qvt.declarative.emof.QVTCore.impl.AssignmentImpl#getValue <em>Value</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class AssignmentImpl extends ElementImpl implements Assignment {
/**
* The default value of the '{@link #getIsDefault() <em>Is Default</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIsDefault()
* @generated
* @ordered
*/
protected static final Boolean IS_DEFAULT_EDEFAULT = null;
/**
* The cached value of the '{@link #getIsDefault() <em>Is Default</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getIsDefault()
* @generated
* @ordered
*/
protected Boolean isDefault = IS_DEFAULT_EDEFAULT;
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected OclExpression value;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected AssignmentImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return QVTCorePackage.Literals.ASSIGNMENT;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public BottomPattern getBottomPattern() {
if (eContainerFeatureID() != QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN) return null;
return (BottomPattern)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetBottomPattern(BottomPattern newBottomPattern, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newBottomPattern, QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setBottomPattern(BottomPattern newBottomPattern) {
if (newBottomPattern != eInternalContainer() || (eContainerFeatureID() != QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN && newBottomPattern != null)) {
if (EcoreUtil.isAncestor(this, newBottomPattern))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newBottomPattern != null)
msgs = ((InternalEObject)newBottomPattern).eInverseAdd(this, QVTCorePackage.BOTTOM_PATTERN__ASSIGNMENT, BottomPattern.class, msgs);
msgs = basicSetBottomPattern(newBottomPattern, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN, newBottomPattern, newBottomPattern));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Boolean getIsDefault() {
return isDefault;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setIsDefault(Boolean newIsDefault) {
Boolean oldIsDefault = isDefault;
isDefault = newIsDefault;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, QVTCorePackage.ASSIGNMENT__IS_DEFAULT, oldIsDefault, isDefault));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public OclExpression getValue() {
return value;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetValue(OclExpression newValue, NotificationChain msgs) {
OclExpression oldValue = value;
value = newValue;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, QVTCorePackage.ASSIGNMENT__VALUE, oldValue, newValue);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setValue(OclExpression newValue) {
if (newValue != value) {
NotificationChain msgs = null;
if (value != null)
msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - QVTCorePackage.ASSIGNMENT__VALUE, null, msgs);
if (newValue != null)
msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - QVTCorePackage.ASSIGNMENT__VALUE, null, msgs);
msgs = basicSetValue(newValue, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, QVTCorePackage.ASSIGNMENT__VALUE, newValue, newValue));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetBottomPattern((BottomPattern)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 QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN:
return basicSetBottomPattern(null, msgs);
case QVTCorePackage.ASSIGNMENT__VALUE:
return basicSetValue(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN:
return eInternalContainer().eInverseRemove(this, QVTCorePackage.BOTTOM_PATTERN__ASSIGNMENT, BottomPattern.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 QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN:
return getBottomPattern();
case QVTCorePackage.ASSIGNMENT__IS_DEFAULT:
return getIsDefault();
case QVTCorePackage.ASSIGNMENT__VALUE:
return getValue();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN:
setBottomPattern((BottomPattern)newValue);
return;
case QVTCorePackage.ASSIGNMENT__IS_DEFAULT:
setIsDefault((Boolean)newValue);
return;
case QVTCorePackage.ASSIGNMENT__VALUE:
setValue((OclExpression)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN:
setBottomPattern((BottomPattern)null);
return;
case QVTCorePackage.ASSIGNMENT__IS_DEFAULT:
setIsDefault(IS_DEFAULT_EDEFAULT);
return;
case QVTCorePackage.ASSIGNMENT__VALUE:
setValue((OclExpression)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case QVTCorePackage.ASSIGNMENT__BOTTOM_PATTERN:
return getBottomPattern() != null;
case QVTCorePackage.ASSIGNMENT__IS_DEFAULT:
return IS_DEFAULT_EDEFAULT == null ? isDefault != null : !IS_DEFAULT_EDEFAULT.equals(isDefault);
case QVTCorePackage.ASSIGNMENT__VALUE:
return value != null;
}
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(" (isDefault: ");
result.append(isDefault);
result.append(')');
return result.toString();
}
} //AssignmentImpl