blob: 2c54b256067a12453a0248d68808674f10f9d891 [file] [log] [blame]
/*******************************************************************************
* 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.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.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.Behavior;
import org.eclipse.ocl.pivot.Comment;
import org.eclipse.ocl.pivot.Constraint;
import org.eclipse.ocl.pivot.Element;
import org.eclipse.ocl.pivot.ElementExtension;
import org.eclipse.ocl.pivot.Operation;
import org.eclipse.ocl.pivot.PivotPackage;
import org.eclipse.ocl.pivot.Property;
import org.eclipse.ocl.pivot.Pseudostate;
import org.eclipse.ocl.pivot.Region;
import org.eclipse.ocl.pivot.State;
import org.eclipse.ocl.pivot.StateMachine;
import org.eclipse.ocl.pivot.StereotypeExtender;
import org.eclipse.ocl.pivot.TemplateBinding;
import org.eclipse.ocl.pivot.TemplateSignature;
import org.eclipse.ocl.pivot.TemplateableElement;
import org.eclipse.ocl.pivot.Transition;
import org.eclipse.ocl.pivot.util.Visitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>State Machine</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.pivot.internal.StateMachineImpl#getExtendedStateMachines <em>Extended State Machines</em>}</li>
* <li>{@link org.eclipse.ocl.pivot.internal.StateMachineImpl#getOwnedConnectionPoints <em>Owned Connection Points</em>}</li>
* <li>{@link org.eclipse.ocl.pivot.internal.StateMachineImpl#getOwnedRegions <em>Owned Regions</em>}</li>
* <li>{@link org.eclipse.ocl.pivot.internal.StateMachineImpl#getSubmachineStates <em>Submachine States</em>}</li>
* </ul>
*
* @generated
*/
public class StateMachineImpl extends BehaviorImpl implements StateMachine
{
/**
* The number of structural features of the '<em>State Machine</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int STATE_MACHINE_FEATURE_COUNT = BehaviorImpl.BEHAVIOR_FEATURE_COUNT + 4;
/**
* The number of operations of the '<em>State Machine</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int STATE_MACHINE_OPERATION_COUNT = BehaviorImpl.BEHAVIOR_OPERATION_COUNT + 0;
/**
* The cached value of the '{@link #getExtendedStateMachines() <em>Extended State Machines</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getExtendedStateMachines()
* @generated
* @ordered
*/
protected EList<StateMachine> extendedStateMachines;
/**
* The cached value of the '{@link #getOwnedConnectionPoints() <em>Owned Connection Points</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedConnectionPoints()
* @generated
* @ordered
*/
protected EList<Pseudostate> ownedConnectionPoints;
/**
* The cached value of the '{@link #getOwnedRegions() <em>Owned Regions</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedRegions()
* @generated
* @ordered
*/
protected EList<Region> ownedRegions;
/**
* The cached value of the '{@link #getSubmachineStates() <em>Submachine States</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getSubmachineStates()
* @generated
* @ordered
*/
protected EList<State> submachineStates;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected StateMachineImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return PivotPackage.Literals.STATE_MACHINE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<StateMachine> getExtendedStateMachines()
{
if (extendedStateMachines == null)
{
extendedStateMachines = new EObjectResolvingEList<StateMachine>(StateMachine.class, this, 21);
}
return extendedStateMachines;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<Pseudostate> getOwnedConnectionPoints()
{
if (ownedConnectionPoints == null)
{
ownedConnectionPoints = new EObjectContainmentWithInverseEList<Pseudostate>(Pseudostate.class, this, 22, 10);
}
return ownedConnectionPoints;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<Region> getOwnedRegions()
{
if (ownedRegions == null)
{
ownedRegions = new EObjectContainmentWithInverseEList<Region>(Region.class, this, 23, 10);
}
return ownedRegions;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public List<State> getSubmachineStates()
{
if (submachineStates == null)
{
submachineStates = new EObjectWithInverseResolvingEList<State>(State.class, this, 24, 22);
}
return submachineStates;
}
/**
* <!-- 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 6:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedBindings()).basicAdd(otherEnd, msgs);
case 7:
if (ownedSignature != null)
msgs = ((InternalEObject)ownedSignature).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (7), null, msgs);
return basicSetOwnedSignature((TemplateSignature)otherEnd, msgs);
case 9:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getExtenders()).basicAdd(otherEnd, msgs);
case 16:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedOperations()).basicAdd(otherEnd, msgs);
case 17:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedProperties()).basicAdd(otherEnd, msgs);
case 18:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwningPackage((org.eclipse.ocl.pivot.Package)otherEnd, msgs);
case 20:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetOwningTransition((Transition)otherEnd, msgs);
case 22:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedConnectionPoints()).basicAdd(otherEnd, msgs);
case 23:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedRegions()).basicAdd(otherEnd, msgs);
case 24:
return ((InternalEList<InternalEObject>)(InternalEList<?>)getSubmachineStates()).basicAdd(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<?>)getOwnedConstraints()).basicRemove(otherEnd, msgs);
case 6:
return ((InternalEList<?>)getOwnedBindings()).basicRemove(otherEnd, msgs);
case 7:
return basicSetOwnedSignature(null, msgs);
case 9:
return ((InternalEList<?>)getExtenders()).basicRemove(otherEnd, msgs);
case 14:
return ((InternalEList<?>)getOwnedBehaviors()).basicRemove(otherEnd, msgs);
case 15:
return ((InternalEList<?>)getOwnedInvariants()).basicRemove(otherEnd, msgs);
case 16:
return ((InternalEList<?>)getOwnedOperations()).basicRemove(otherEnd, msgs);
case 17:
return ((InternalEList<?>)getOwnedProperties()).basicRemove(otherEnd, msgs);
case 18:
return basicSetOwningPackage(null, msgs);
case 20:
return basicSetOwningTransition(null, msgs);
case 22:
return ((InternalEList<?>)getOwnedConnectionPoints()).basicRemove(otherEnd, msgs);
case 23:
return ((InternalEList<?>)getOwnedRegions()).basicRemove(otherEnd, msgs);
case 24:
return ((InternalEList<?>)getSubmachineStates()).basicRemove(otherEnd, msgs);
}
return eDynamicInverseRemove(otherEnd, featureID, 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 getOwnedConstraints();
case 6:
return getOwnedBindings();
case 7:
return getOwnedSignature();
case 8:
return getUnspecializedElement();
case 9:
return getExtenders();
case 10:
return getInstanceClassName();
case 11:
return isIsAbstract();
case 12:
return isIsActive();
case 13:
return isIsInterface();
case 14:
return getOwnedBehaviors();
case 15:
return getOwnedInvariants();
case 16:
return getOwnedOperations();
case 17:
return getOwnedProperties();
case 18:
return getOwningPackage();
case 19:
return getSuperClasses();
case 20:
return getOwningTransition();
case 21:
return getExtendedStateMachines();
case 22:
return getOwnedConnectionPoints();
case 23:
return getOwnedRegions();
case 24:
return getSubmachineStates();
}
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 5:
getOwnedConstraints().clear();
getOwnedConstraints().addAll((Collection<? extends Constraint>)newValue);
return;
case 6:
getOwnedBindings().clear();
getOwnedBindings().addAll((Collection<? extends TemplateBinding>)newValue);
return;
case 7:
setOwnedSignature((TemplateSignature)newValue);
return;
case 8:
setUnspecializedElement((TemplateableElement)newValue);
return;
case 9:
getExtenders().clear();
getExtenders().addAll((Collection<? extends StereotypeExtender>)newValue);
return;
case 10:
setInstanceClassName((String)newValue);
return;
case 11:
setIsAbstract((Boolean)newValue);
return;
case 12:
setIsActive((Boolean)newValue);
return;
case 13:
setIsInterface((Boolean)newValue);
return;
case 14:
getOwnedBehaviors().clear();
getOwnedBehaviors().addAll((Collection<? extends Behavior>)newValue);
return;
case 15:
getOwnedInvariants().clear();
getOwnedInvariants().addAll((Collection<? extends Constraint>)newValue);
return;
case 16:
getOwnedOperations().clear();
getOwnedOperations().addAll((Collection<? extends Operation>)newValue);
return;
case 17:
getOwnedProperties().clear();
getOwnedProperties().addAll((Collection<? extends Property>)newValue);
return;
case 18:
setOwningPackage((org.eclipse.ocl.pivot.Package)newValue);
return;
case 19:
getSuperClasses().clear();
getSuperClasses().addAll((Collection<? extends org.eclipse.ocl.pivot.Class>)newValue);
return;
case 20:
setOwningTransition((Transition)newValue);
return;
case 21:
getExtendedStateMachines().clear();
getExtendedStateMachines().addAll((Collection<? extends StateMachine>)newValue);
return;
case 22:
getOwnedConnectionPoints().clear();
getOwnedConnectionPoints().addAll((Collection<? extends Pseudostate>)newValue);
return;
case 23:
getOwnedRegions().clear();
getOwnedRegions().addAll((Collection<? extends Region>)newValue);
return;
case 24:
getSubmachineStates().clear();
getSubmachineStates().addAll((Collection<? extends State>)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 5:
getOwnedConstraints().clear();
return;
case 6:
getOwnedBindings().clear();
return;
case 7:
setOwnedSignature((TemplateSignature)null);
return;
case 8:
setUnspecializedElement((TemplateableElement)null);
return;
case 9:
getExtenders().clear();
return;
case 10:
setInstanceClassName(INSTANCE_CLASS_NAME_EDEFAULT);
return;
case 11:
setIsAbstract(IS_ABSTRACT_EDEFAULT);
return;
case 12:
setIsActive(IS_ACTIVE_EDEFAULT);
return;
case 13:
setIsInterface(IS_INTERFACE_EDEFAULT);
return;
case 14:
getOwnedBehaviors().clear();
return;
case 15:
getOwnedInvariants().clear();
return;
case 16:
getOwnedOperations().clear();
return;
case 17:
getOwnedProperties().clear();
return;
case 18:
setOwningPackage((org.eclipse.ocl.pivot.Package)null);
return;
case 19:
getSuperClasses().clear();
return;
case 20:
setOwningTransition((Transition)null);
return;
case 21:
getExtendedStateMachines().clear();
return;
case 22:
getOwnedConnectionPoints().clear();
return;
case 23:
getOwnedRegions().clear();
return;
case 24:
getSubmachineStates().clear();
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 ownedConstraints != null && !ownedConstraints.isEmpty();
case 6:
return ownedBindings != null && !ownedBindings.isEmpty();
case 7:
return ownedSignature != null;
case 8:
return unspecializedElement != null;
case 9:
return extenders != null && !extenders.isEmpty();
case 10:
return INSTANCE_CLASS_NAME_EDEFAULT == null ? instanceClassName != null : !INSTANCE_CLASS_NAME_EDEFAULT.equals(instanceClassName);
case 11:
return ((eFlags & IS_ABSTRACT_EFLAG) != 0) != IS_ABSTRACT_EDEFAULT;
case 12:
return ((eFlags & IS_ACTIVE_EFLAG) != 0) != IS_ACTIVE_EDEFAULT;
case 13:
return ((eFlags & IS_INTERFACE_EFLAG) != 0) != IS_INTERFACE_EDEFAULT;
case 14:
return ownedBehaviors != null && !ownedBehaviors.isEmpty();
case 15:
return ownedInvariants != null && !ownedInvariants.isEmpty();
case 16:
return ownedOperations != null && !ownedOperations.isEmpty();
case 17:
return ownedProperties != null && !ownedProperties.isEmpty();
case 18:
return getOwningPackage() != null;
case 19:
return superClasses != null && !superClasses.isEmpty();
case 20:
return getOwningTransition() != null;
case 21:
return extendedStateMachines != null && !extendedStateMachines.isEmpty();
case 22:
return ownedConnectionPoints != null && !ownedConnectionPoints.isEmpty();
case 23:
return ownedRegions != null && !ownedRegions.isEmpty();
case 24:
return submachineStates != null && !submachineStates.isEmpty();
}
return eDynamicIsSet(featureID);
}
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
return visitor.visitStateMachine(this);
}
} //StateMachineImpl