blob: 803582c4101f2b0f9d7850cf16c0c99d1cfa8869 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013, 2018 Willink Transformations 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:
* E.D.Willink - Initial API and implementation
*******************************************************************************/
package org.eclipse.qvtd.codegen.qvticgmodel.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.EClassifier;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement;
import org.eclipse.ocl.examples.codegen.cgmodel.impl.CGValuedElementImpl;
import org.eclipse.ocl.examples.codegen.cgmodel.util.CGModelVisitor;
import org.eclipse.qvtd.codegen.qvticgmodel.CGMappingCall;
import org.eclipse.qvtd.codegen.qvticgmodel.CGMappingCallBinding;
import org.eclipse.qvtd.codegen.qvticgmodel.QVTiCGModelPackage;
import org.eclipse.qvtd.codegen.qvticgmodel.util.QVTiCGModelVisitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>CG Mapping Call Binding</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGMappingCallBindingImpl#getOwnedValue <em>Owned Value</em>}</li>
* <li>{@link org.eclipse.qvtd.codegen.qvticgmodel.impl.CGMappingCallBindingImpl#getOwningMappingCall <em>Owning Mapping Call</em>}</li>
* </ul>
*
* @generated
*/
public class CGMappingCallBindingImpl extends CGValuedElementImpl implements CGMappingCallBinding {
/**
* The number of structural features of the '<em>CG Mapping Call Binding</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int CG_MAPPING_CALL_BINDING_FEATURE_COUNT = CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 2;
/**
* The cached value of the '{@link #getOwnedValue() <em>Owned Value</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedValue()
* @generated
* @ordered
*/
protected CGValuedElement ownedValue;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGMappingCallBindingImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return QVTiCGModelPackage.Literals.CG_MAPPING_CALL_BINDING;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGValuedElement getOwnedValue() {
return ownedValue;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedValue(CGValuedElement newOwnedValue, NotificationChain msgs) {
CGValuedElement oldOwnedValue = ownedValue;
ownedValue = newOwnedValue;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0, oldOwnedValue, newOwnedValue);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwnedValue(CGValuedElement newOwnedValue) {
if (newOwnedValue != ownedValue) {
NotificationChain msgs = null;
if (ownedValue != null)
msgs = ((InternalEObject)ownedValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0), null, msgs);
if (newOwnedValue != null)
msgs = ((InternalEObject)newOwnedValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - (CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0), null, msgs);
msgs = basicSetOwnedValue(newOwnedValue, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0, newOwnedValue, newOwnedValue));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGMappingCall getOwningMappingCall() {
if (eContainerFeatureID() != (CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1)) return null;
return (CGMappingCall)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwningMappingCall(CGMappingCall newOwningMappingCall, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newOwningMappingCall, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwningMappingCall(CGMappingCall newOwningMappingCall) {
if (newOwningMappingCall != eInternalContainer() || (eContainerFeatureID() != (CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1) && newOwningMappingCall != null)) {
if (EcoreUtil.isAncestor(this, newOwningMappingCall))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newOwningMappingCall != null)
msgs = ((InternalEObject)newOwningMappingCall).eInverseAdd(this, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0, CGMappingCall.class, msgs);
msgs = basicSetOwningMappingCall(newOwningMappingCall, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1, newOwningMappingCall, newOwningMappingCall));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwningMappingCall((CGMappingCall)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 CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
return basicSetOwnedValue(null, msgs);
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
return basicSetOwningMappingCall(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
return eInternalContainer().eInverseRemove(this, CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0, CGMappingCall.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 CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
return getOwnedValue();
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
return getOwningMappingCall();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
setOwnedValue((CGValuedElement)newValue);
return;
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
setOwningMappingCall((CGMappingCall)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
setOwnedValue((CGValuedElement)null);
return;
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
setOwningMappingCall((CGMappingCall)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 0:
return ownedValue != null;
case CGValuedElementImpl.CG_VALUED_ELEMENT_FEATURE_COUNT + 1:
return getOwningMappingCall() != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return (R) ((QVTiCGModelVisitor<?>)visitor).visitCGMappingCallBinding(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable EClassifier getEcoreClassifier() {
return ownedValue != null ? ownedValue.getEcoreClassifier() : null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isBoxed() {
return (ownedValue != null) && ownedValue.isBoxed();
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isCommonable() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isEcore() {
return (ownedValue != null) && ownedValue.isEcore();
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
if (this == thatValue) {
return Boolean.TRUE;
}
else {
return Boolean.FALSE;
}
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isGlobal() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUnboxed() {
return (ownedValue != null) && ownedValue.isUnboxed();
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUncommonable() {
return true;
}
} //CGMappingCallBindingImpl