blob: 3415e227553991f0f12bbc844448e641976496f3 [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2013, 2019 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
*
* </copyright>
*/
package org.eclipse.qvtd.pivot.qvtschedule.impl;
import java.util.List;
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.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.internal.NamedElementImpl;
import org.eclipse.ocl.pivot.util.Visitor;
import org.eclipse.qvtd.pivot.qvtschedule.LoadingPartition;
import org.eclipse.qvtd.pivot.qvtschedule.Node;
import org.eclipse.qvtd.pivot.qvtschedule.QVTschedulePackage;
import org.eclipse.qvtd.pivot.qvtschedule.RootRegion;
import org.eclipse.qvtd.pivot.qvtschedule.LoadingRegion;
import org.eclipse.qvtd.pivot.qvtschedule.util.QVTscheduleVisitor;
import org.eclipse.qvtd.pivot.qvtschedule.utilities.QVTscheduleConstants;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Root Composition Region</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.qvtd.pivot.qvtschedule.impl.LoadingRegionImpl#getLoadingPartition <em>Loading Partition</em>}</li>
* <li>{@link org.eclipse.qvtd.pivot.qvtschedule.impl.LoadingRegionImpl#getOwningRootRegion <em>Owning Root Region</em>}</li>
* <li>{@link org.eclipse.qvtd.pivot.qvtschedule.impl.LoadingRegionImpl#getTargetName <em>Target Name</em>}</li>
* </ul>
*
* @generated
*/
public class LoadingRegionImpl extends RegionImpl implements LoadingRegion {
/**
* The number of structural features of the '<em>Loading Region</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int LOADING_REGION_FEATURE_COUNT = RegionImpl.REGION_FEATURE_COUNT + 3;
/**
* The number of operations of the '<em>Loading Region</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int LOADING_REGION_OPERATION_COUNT = RegionImpl.REGION_OPERATION_COUNT + 0;
/**
* The cached value of the '{@link #getLoadingPartition() <em>Loading Partition</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getLoadingPartition()
* @generated
* @ordered
*/
protected LoadingPartition loadingPartition;
/**
* The default value of the '{@link #getTargetName() <em>Target Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTargetName()
* @generated
* @ordered
*/
protected static final String TARGET_NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getTargetName() <em>Target Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTargetName()
* @generated
* @ordered
*/
protected String targetName = TARGET_NAME_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected LoadingRegionImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return QVTschedulePackage.Literals.LOADING_REGION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public LoadingPartition getLoadingPartition() {
if (loadingPartition != null && loadingPartition.eIsProxy()) {
InternalEObject oldLoadingPartition = (InternalEObject)loadingPartition;
loadingPartition = (LoadingPartition)eResolveProxy(oldLoadingPartition);
if (loadingPartition != oldLoadingPartition) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5, oldLoadingPartition, loadingPartition));
}
}
return loadingPartition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public LoadingPartition basicGetLoadingPartition() {
return loadingPartition;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetLoadingPartition(LoadingPartition newLoadingPartition, NotificationChain msgs) {
LoadingPartition oldLoadingPartition = loadingPartition;
loadingPartition = newLoadingPartition;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5, oldLoadingPartition, newLoadingPartition);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setLoadingPartition(LoadingPartition newLoadingPartition) {
if (newLoadingPartition != loadingPartition) {
NotificationChain msgs = null;
if (loadingPartition != null)
msgs = ((InternalEObject)loadingPartition).eInverseRemove(this, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7, LoadingPartition.class, msgs);
if (newLoadingPartition != null)
msgs = ((InternalEObject)newLoadingPartition).eInverseAdd(this, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7, LoadingPartition.class, msgs);
msgs = basicSetLoadingPartition(newLoadingPartition, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5, newLoadingPartition, newLoadingPartition));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public RootRegion getOwningRootRegion() {
if (eContainerFeatureID() != (NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6)) return null;
return (RootRegion)eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwningRootRegion(RootRegion newOwningRootRegion, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newOwningRootRegion, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwningRootRegion(RootRegion newOwningRootRegion) {
if (newOwningRootRegion != eInternalContainer() || (eContainerFeatureID() != (NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6) && newOwningRootRegion != null)) {
if (EcoreUtil.isAncestor(this, newOwningRootRegion))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newOwningRootRegion != null)
msgs = ((InternalEObject)newOwningRootRegion).eInverseAdd(this, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7, RootRegion.class, msgs);
msgs = basicSetOwningRootRegion(newOwningRootRegion, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6, newOwningRootRegion, newOwningRootRegion));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String getTargetName() {
return targetName;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setTargetName(String newTargetName) {
String oldTargetName = targetName;
targetName = newTargetName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7, oldTargetName, targetName));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5:
if (loadingPartition != null)
msgs = ((InternalEObject)loadingPartition).eInverseRemove(this, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7, LoadingPartition.class, msgs);
return basicSetLoadingPartition((LoadingPartition)otherEnd, msgs);
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwningRootRegion((RootRegion)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 NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5:
return basicSetLoadingPartition(null, msgs);
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6:
return basicSetOwningRootRegion(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6:
return eInternalContainer().eInverseRemove(this, NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7, RootRegion.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 NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5:
if (resolve) return getLoadingPartition();
return basicGetLoadingPartition();
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6:
return getOwningRootRegion();
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7:
return getTargetName();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5:
setLoadingPartition((LoadingPartition)newValue);
return;
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6:
setOwningRootRegion((RootRegion)newValue);
return;
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7:
setTargetName((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5:
setLoadingPartition((LoadingPartition)null);
return;
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6:
setOwningRootRegion((RootRegion)null);
return;
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7:
setTargetName(TARGET_NAME_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 5:
return loadingPartition != null;
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 6:
return getOwningRootRegion() != null;
case NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 7:
return TARGET_NAME_EDEFAULT == null ? targetName != null : !TARGET_NAME_EDEFAULT.equals(targetName);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public @NonNull String toString() {
return super.toString();
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
if (visitor instanceof QVTscheduleVisitor) {
return (R) ((QVTscheduleVisitor<?>)visitor).visitLoadingRegion(this);
}
else {
return super.accept(visitor);
}
}
// @Override
// protected void computeSymbolName(@NonNull SymbolNameBuilder s) {
// s.appendString(QVTscheduleUtil.ROOT_MAPPING_NAME);
// }
@Override
public @NonNull List<Node> getHeadNodes() {
return QVTscheduleConstants.EMPTY_NODE_LIST;
}
// @Override
// protected @NonNull String getSymbolNamePrefix() {
// return "r_";
// }
@Override
public boolean isLoadingRegion() {
return true;
}
@Override
public RootRegion getContainingRootRegion() {
return getOwningRootRegion();
}
} //RootCompositionRegionImpl