blob: 7768784c7856e8873a79b4343e2b429bd736c367 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2013, 2015 Willink Transformations 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
*******************************************************************************/
package org.eclipse.ocl.examples.autogen.autocgmodel.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.EStructuralFeature;
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.autogen.autocgmodel.AutoCGModelPackage;
import org.eclipse.ocl.examples.autogen.autocgmodel.CGContainmentBody;
import org.eclipse.ocl.examples.autogen.autocgmodel.CGContainmentPart;
import org.eclipse.ocl.examples.autogen.autocgmodel.util.AutoCGModelVisitor;
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;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>CG Containment Part</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.examples.autogen.autocgmodel.impl.CGContainmentPartImpl#getContainmentBody <em>Containment Body</em>}</li>
* <li>{@link org.eclipse.ocl.examples.autogen.autocgmodel.impl.CGContainmentPartImpl#getInit <em>Init</em>}</li>
* <li>{@link org.eclipse.ocl.examples.autogen.autocgmodel.impl.CGContainmentPartImpl#getEStructuralFeature <em>EStructural Feature</em>}</li>
* </ul>
*
* @generated
*/
public class CGContainmentPartImpl extends CGValuedElementImpl implements CGContainmentPart {
/**
* The cached value of the '{@link #getInit() <em>Init</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInit()
* @generated
* @ordered
*/
protected CGValuedElement init;
/**
* The cached value of the '{@link #getEStructuralFeature() <em>EStructural Feature</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getEStructuralFeature()
* @generated
* @ordered
*/
protected EStructuralFeature eStructuralFeature;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CGContainmentPartImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return AutoCGModelPackage.Literals.CG_CONTAINMENT_PART;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGContainmentBody getContainmentBody() {
if (eContainerFeatureID() != AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY) return null;
return (CGContainmentBody)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetContainmentBody(CGContainmentBody newContainmentBody, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newContainmentBody, AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setContainmentBody(CGContainmentBody newContainmentBody) {
if (newContainmentBody != eInternalContainer() || (eContainerFeatureID() != AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY && newContainmentBody != null)) {
if (EcoreUtil.isAncestor(this, newContainmentBody))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newContainmentBody != null)
msgs = ((InternalEObject)newContainmentBody).eInverseAdd(this, AutoCGModelPackage.CG_CONTAINMENT_BODY__PARTS, CGContainmentBody.class, msgs);
msgs = basicSetContainmentBody(newContainmentBody, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY, newContainmentBody, newContainmentBody));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public CGValuedElement getInit() {
return init;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetInit(CGValuedElement newInit, NotificationChain msgs) {
CGValuedElement oldInit = init;
init = newInit;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AutoCGModelPackage.CG_CONTAINMENT_PART__INIT, oldInit, newInit);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setInit(CGValuedElement newInit) {
if (newInit != init) {
NotificationChain msgs = null;
if (init != null)
msgs = ((InternalEObject)init).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AutoCGModelPackage.CG_CONTAINMENT_PART__INIT, null, msgs);
if (newInit != null)
msgs = ((InternalEObject)newInit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AutoCGModelPackage.CG_CONTAINMENT_PART__INIT, null, msgs);
msgs = basicSetInit(newInit, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AutoCGModelPackage.CG_CONTAINMENT_PART__INIT, newInit, newInit));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EStructuralFeature getEStructuralFeature() {
return eStructuralFeature;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setEStructuralFeature(EStructuralFeature newEStructuralFeature) {
EStructuralFeature oldEStructuralFeature = eStructuralFeature;
eStructuralFeature = newEStructuralFeature;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AutoCGModelPackage.CG_CONTAINMENT_PART__ESTRUCTURAL_FEATURE, oldEStructuralFeature, eStructuralFeature));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetContainmentBody((CGContainmentBody)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 AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY:
return basicSetContainmentBody(null, msgs);
case AutoCGModelPackage.CG_CONTAINMENT_PART__INIT:
return basicSetInit(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY:
return eInternalContainer().eInverseRemove(this, AutoCGModelPackage.CG_CONTAINMENT_BODY__PARTS, CGContainmentBody.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 AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY:
return getContainmentBody();
case AutoCGModelPackage.CG_CONTAINMENT_PART__INIT:
return getInit();
case AutoCGModelPackage.CG_CONTAINMENT_PART__ESTRUCTURAL_FEATURE:
return getEStructuralFeature();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY:
setContainmentBody((CGContainmentBody)newValue);
return;
case AutoCGModelPackage.CG_CONTAINMENT_PART__INIT:
setInit((CGValuedElement)newValue);
return;
case AutoCGModelPackage.CG_CONTAINMENT_PART__ESTRUCTURAL_FEATURE:
setEStructuralFeature((EStructuralFeature)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY:
setContainmentBody((CGContainmentBody)null);
return;
case AutoCGModelPackage.CG_CONTAINMENT_PART__INIT:
setInit((CGValuedElement)null);
return;
case AutoCGModelPackage.CG_CONTAINMENT_PART__ESTRUCTURAL_FEATURE:
setEStructuralFeature((EStructuralFeature)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case AutoCGModelPackage.CG_CONTAINMENT_PART__CONTAINMENT_BODY:
return getContainmentBody() != null;
case AutoCGModelPackage.CG_CONTAINMENT_PART__INIT:
return init != null;
case AutoCGModelPackage.CG_CONTAINMENT_PART__ESTRUCTURAL_FEATURE:
return eStructuralFeature != null;
}
return super.eIsSet(featureID);
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public @Nullable <R> R accept(@NonNull CGModelVisitor<R> visitor) {
return (R) ((AutoCGModelVisitor<?>)visitor).visitCGContainmentPart(this);
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable EClassifier getEcoreClassifier() {
return null;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isAssertedNonNull() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isBoxed() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isCommonable() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isEcore() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public @Nullable Boolean isEquivalentToInternal(@NonNull CGValuedElement thatValue) {
throw new UnsupportedOperationException(getClass().getName() + ".isEquivalentToInternal()");
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isGlobal() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isNonNull() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isNull() {
return false;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUnboxed() {
return true;
}
/**
* {@inheritDoc}
* @generated
*/
@Override
public boolean isUncommonable() {
return true;
}
} //CGContainmentPartImpl