| /******************************************************************************* |
| * Copyright (c) 2012, 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 |
| *******************************************************************************/ |
| package org.eclipse.ocl.pivot.internal; |
| |
| import java.util.Collection; |
| import java.util.List; |
| |
| 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.EObjectWithInverseResolvingEList; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.pivot.Comment; |
| import org.eclipse.ocl.pivot.Element; |
| import org.eclipse.ocl.pivot.ElementExtension; |
| import org.eclipse.ocl.pivot.PivotPackage; |
| import org.eclipse.ocl.pivot.Region; |
| import org.eclipse.ocl.pivot.Transition; |
| import org.eclipse.ocl.pivot.Vertex; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Vertex</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.VertexImpl#getIncomingTransitions <em>Incoming Transitions</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.VertexImpl#getOutgoingTransitions <em>Outgoing Transitions</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.VertexImpl#getOwningRegion <em>Owning Region</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public abstract class VertexImpl extends NamedElementImpl implements Vertex |
| { |
| /** |
| * The number of structural features of the '<em>Vertex</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int VERTEX_FEATURE_COUNT = NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 3; |
| /** |
| * The number of operations of the '<em>Vertex</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int VERTEX_OPERATION_COUNT = NamedElementImpl.NAMED_ELEMENT_OPERATION_COUNT + 0; |
| /** |
| * The cached value of the '{@link #getIncomingTransitions() <em>Incoming Transitions</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIncomingTransitions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Transition> incomingTransitions; |
| /** |
| * The cached value of the '{@link #getOutgoingTransitions() <em>Outgoing Transitions</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOutgoingTransitions() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Transition> outgoingTransitions; |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected VertexImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return PivotPackage.Literals.VERTEX; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public List<Transition> getIncomingTransitions() |
| { |
| if (incomingTransitions == null) |
| { |
| incomingTransitions = new EObjectWithInverseResolvingEList<Transition>(Transition.class, this, 5, 12); |
| } |
| return incomingTransitions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public List<Transition> getOutgoingTransitions() |
| { |
| if (outgoingTransitions == null) |
| { |
| outgoingTransitions = new EObjectWithInverseResolvingEList<Transition>(Transition.class, this, 6, 11); |
| } |
| return outgoingTransitions; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Region getOwningRegion() |
| { |
| if (eContainerFeatureID() != (7)) return null; |
| return (Region)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwningRegion(Region newOwningRegion, NotificationChain msgs) |
| { |
| msgs = eBasicSetContainer((InternalEObject)newOwningRegion, 7, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwningRegion(Region newOwningRegion) |
| { |
| if (newOwningRegion != eInternalContainer() || (eContainerFeatureID() != (7) && newOwningRegion != null)) |
| { |
| if (EcoreUtil.isAncestor(this, newOwningRegion)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newOwningRegion != null) |
| msgs = ((InternalEObject)newOwningRegion).eInverseAdd(this, 7, Region.class, msgs); |
| msgs = basicSetOwningRegion(newOwningRegion, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 7, newOwningRegion, newOwningRegion)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case 0: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getAnnotatingComments()).basicAdd(otherEnd, msgs); |
| case 2: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedComments()).basicAdd(otherEnd, msgs); |
| case 3: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedExtensions()).basicAdd(otherEnd, msgs); |
| case 5: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getIncomingTransitions()).basicAdd(otherEnd, msgs); |
| case 6: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOutgoingTransitions()).basicAdd(otherEnd, msgs); |
| case 7: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetOwningRegion((Region)otherEnd, msgs); |
| } |
| return eDynamicInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case 0: |
| return ((InternalEList<?>)getAnnotatingComments()).basicRemove(otherEnd, msgs); |
| case 1: |
| return ((InternalEList<?>)getOwnedAnnotations()).basicRemove(otherEnd, msgs); |
| case 2: |
| return ((InternalEList<?>)getOwnedComments()).basicRemove(otherEnd, msgs); |
| case 3: |
| return ((InternalEList<?>)getOwnedExtensions()).basicRemove(otherEnd, msgs); |
| case 5: |
| return ((InternalEList<?>)getIncomingTransitions()).basicRemove(otherEnd, msgs); |
| case 6: |
| return ((InternalEList<?>)getOutgoingTransitions()).basicRemove(otherEnd, msgs); |
| case 7: |
| return basicSetOwningRegion(null, msgs); |
| } |
| return eDynamicInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) |
| { |
| switch (eContainerFeatureID()) |
| { |
| case 7: |
| return eInternalContainer().eInverseRemove(this, 7, Region.class, msgs); |
| } |
| return eDynamicBasicRemoveFromContainer(msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case 0: |
| return getAnnotatingComments(); |
| case 1: |
| return getOwnedAnnotations(); |
| case 2: |
| return getOwnedComments(); |
| case 3: |
| return getOwnedExtensions(); |
| case 4: |
| return getName(); |
| case 5: |
| return getIncomingTransitions(); |
| case 6: |
| return getOutgoingTransitions(); |
| case 7: |
| return getOwningRegion(); |
| } |
| return eDynamicGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case 0: |
| getAnnotatingComments().clear(); |
| getAnnotatingComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case 1: |
| getOwnedAnnotations().clear(); |
| getOwnedAnnotations().addAll((Collection<? extends Element>)newValue); |
| return; |
| case 2: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case 3: |
| getOwnedExtensions().clear(); |
| getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue); |
| return; |
| case 4: |
| setName((String)newValue); |
| return; |
| case 7: |
| setOwningRegion((Region)newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case 0: |
| getAnnotatingComments().clear(); |
| return; |
| case 1: |
| getOwnedAnnotations().clear(); |
| return; |
| case 2: |
| getOwnedComments().clear(); |
| return; |
| case 3: |
| getOwnedExtensions().clear(); |
| return; |
| case 4: |
| setName(NAME_EDEFAULT); |
| return; |
| case 7: |
| setOwningRegion((Region)null); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case 0: |
| return annotatingComments != null && !annotatingComments.isEmpty(); |
| case 1: |
| return ownedAnnotations != null && !ownedAnnotations.isEmpty(); |
| case 2: |
| return ownedComments != null && !ownedComments.isEmpty(); |
| case 3: |
| return ownedExtensions != null && !ownedExtensions.isEmpty(); |
| case 4: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case 5: |
| return incomingTransitions != null && !incomingTransitions.isEmpty(); |
| case 6: |
| return outgoingTransitions != null && !outgoingTransitions.isEmpty(); |
| case 7: |
| return getOwningRegion() != null; |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitVertex(this); |
| } |
| } //VertexImpl |