blob: 1790b6dd4e0b8472aa1babcecd9f3b87019b1eda [file] [log] [blame]
/*
* Copyright (c) 2003, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*
* $Id: InteractionConstraintImpl.java,v 1.5 2004/06/02 05:02:26 khussey Exp $
*/
package org.eclipse.uml2.impl;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
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.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.uml2.InteractionConstraint;
import org.eclipse.uml2.Namespace;
import org.eclipse.uml2.StringExpression;
import org.eclipse.uml2.TemplateParameter;
import org.eclipse.uml2.TemplateSignature;
import org.eclipse.uml2.UML2Package;
import org.eclipse.uml2.ValueSpecification;
import org.eclipse.uml2.VisibilityKind;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Interaction Constraint</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.uml2.impl.InteractionConstraintImpl#getMinint <em>Minint</em>}</li>
* <li>{@link org.eclipse.uml2.impl.InteractionConstraintImpl#getMaxint <em>Maxint</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class InteractionConstraintImpl extends ConstraintImpl implements InteractionConstraint {
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = "Copyright (c) 2003, 2004 IBM Corporation and others."; //$NON-NLS-1$
/**
* The cached value of the '{@link #getMinint() <em>Minint</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMinint()
* @generated
* @ordered
*/
protected ValueSpecification minint = null;
/**
* The cached value of the '{@link #getMaxint() <em>Maxint</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getMaxint()
* @generated
* @ordered
*/
protected ValueSpecification maxint = null;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected InteractionConstraintImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return UML2Package.eINSTANCE.getInteractionConstraint();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification getMinint() {
return minint;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetMinint(ValueSpecification newMinint, NotificationChain msgs) {
ValueSpecification oldMinint = minint;
minint = newMinint;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UML2Package.INTERACTION_CONSTRAINT__MININT, oldMinint, newMinint);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMinint(ValueSpecification newMinint) {
if (newMinint != minint) {
NotificationChain msgs = null;
if (minint != null)
msgs = ((InternalEObject)minint).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UML2Package.INTERACTION_CONSTRAINT__MININT, null, msgs);
if (newMinint != null)
msgs = ((InternalEObject)newMinint).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UML2Package.INTERACTION_CONSTRAINT__MININT, null, msgs);
msgs = basicSetMinint(newMinint, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UML2Package.INTERACTION_CONSTRAINT__MININT, newMinint, newMinint));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification createMinint(EClass eClass) {
ValueSpecification newMinint = (ValueSpecification) eClass.getEPackage().getEFactoryInstance().create(eClass);
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, 0, UML2Package.INTERACTION_CONSTRAINT__MININT, null, newMinint));
}
setMinint(newMinint);
return newMinint;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification getMaxint() {
return maxint;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetMaxint(ValueSpecification newMaxint, NotificationChain msgs) {
ValueSpecification oldMaxint = maxint;
maxint = newMaxint;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UML2Package.INTERACTION_CONSTRAINT__MAXINT, oldMaxint, newMaxint);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setMaxint(ValueSpecification newMaxint) {
if (newMaxint != maxint) {
NotificationChain msgs = null;
if (maxint != null)
msgs = ((InternalEObject)maxint).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UML2Package.INTERACTION_CONSTRAINT__MAXINT, null, msgs);
if (newMaxint != null)
msgs = ((InternalEObject)newMaxint).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UML2Package.INTERACTION_CONSTRAINT__MAXINT, null, msgs);
msgs = basicSetMaxint(newMaxint, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UML2Package.INTERACTION_CONSTRAINT__MAXINT, newMaxint, newMaxint));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ValueSpecification createMaxint(EClass eClass) {
ValueSpecification newMaxint = (ValueSpecification) eClass.getEPackage().getEFactoryInstance().create(eClass);
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, 0, UML2Package.INTERACTION_CONSTRAINT__MAXINT, null, newMaxint));
}
setMaxint(newMaxint);
return newMaxint;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getOwnedElements() {
EList ownedElement = (EList) getCacheAdapter().get(this, UML2Package.eINSTANCE.getElement_OwnedElement());
if (null == ownedElement) {
Set union = new LinkedHashSet();
union.addAll(super.getOwnedElements());
if (null != getMinint()) {
union.add(getMinint());
}
if (null != getMaxint()) {
union.add(getMaxint());
}
ownedElement = new EcoreEList.UnmodifiableEList(this, UML2Package.eINSTANCE.getElement_OwnedElement(), union.size(), union.toArray());
getCacheAdapter().put(this, UML2Package.eINSTANCE.getElement_OwnedElement(), ownedElement);
}
return ownedElement;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
if (featureID >= 0) {
switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
case UML2Package.INTERACTION_CONSTRAINT__EANNOTATIONS:
return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_BINDING:
return ((InternalEList)getTemplateBindings()).basicAdd(otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__OWNED_TEMPLATE_SIGNATURE:
if (ownedTemplateSignature != null)
msgs = ((InternalEObject)ownedTemplateSignature).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UML2Package.INTERACTION_CONSTRAINT__OWNED_TEMPLATE_SIGNATURE, null, msgs);
return basicSetOwnedTemplateSignature((TemplateSignature)otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__CLIENT_DEPENDENCY:
return ((InternalEList)getClientDependencies()).basicAdd(otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_PARAMETER:
if (templateParameter != null)
msgs = ((InternalEObject)templateParameter).eInverseRemove(this, UML2Package.TEMPLATE_PARAMETER__PARAMETERED_ELEMENT, TemplateParameter.class, msgs);
return basicSetTemplateParameter((TemplateParameter)otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER:
if (eContainer != null)
msgs = eBasicRemoveFromContainer(msgs);
return eBasicSetContainer(otherEnd, UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER, msgs);
case UML2Package.INTERACTION_CONSTRAINT__NAMESPACE:
if (eContainer != null)
msgs = eBasicRemoveFromContainer(msgs);
return eBasicSetContainer(otherEnd, UML2Package.INTERACTION_CONSTRAINT__NAMESPACE, msgs);
default:
return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs);
}
}
if (eContainer != null)
msgs = eBasicRemoveFromContainer(msgs);
return eBasicSetContainer(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
if (featureID >= 0) {
switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
case UML2Package.INTERACTION_CONSTRAINT__EANNOTATIONS:
return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__OWNED_COMMENT:
return ((InternalEList)getOwnedComments()).basicRemove(otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_BINDING:
return ((InternalEList)getTemplateBindings()).basicRemove(otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__OWNED_TEMPLATE_SIGNATURE:
return basicSetOwnedTemplateSignature(null, msgs);
case UML2Package.INTERACTION_CONSTRAINT__CLIENT_DEPENDENCY:
return ((InternalEList)getClientDependencies()).basicRemove(otherEnd, msgs);
case UML2Package.INTERACTION_CONSTRAINT__NAME_EXPRESSION:
return basicSetNameExpression(null, msgs);
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_PARAMETER:
return basicSetTemplateParameter(null, msgs);
case UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER:
return eBasicSetContainer(null, UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER, msgs);
case UML2Package.INTERACTION_CONSTRAINT__NAMESPACE:
return eBasicSetContainer(null, UML2Package.INTERACTION_CONSTRAINT__NAMESPACE, msgs);
case UML2Package.INTERACTION_CONSTRAINT__SPECIFICATION:
return basicSetSpecification(null, msgs);
case UML2Package.INTERACTION_CONSTRAINT__MININT:
return basicSetMinint(null, msgs);
case UML2Package.INTERACTION_CONSTRAINT__MAXINT:
return basicSetMaxint(null, msgs);
default:
return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
}
}
return eBasicSetContainer(null, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) {
if (eContainerFeatureID >= 0) {
switch (eContainerFeatureID) {
case UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER:
return eContainer.eInverseRemove(this, UML2Package.TEMPLATE_PARAMETER__OWNED_PARAMETERED_ELEMENT, TemplateParameter.class, msgs);
case UML2Package.INTERACTION_CONSTRAINT__NAMESPACE:
return eContainer.eInverseRemove(this, UML2Package.NAMESPACE__OWNED_RULE, Namespace.class, msgs);
default:
return eDynamicBasicRemoveFromContainer(msgs);
}
}
return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(EStructuralFeature eFeature, boolean resolve) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UML2Package.INTERACTION_CONSTRAINT__EANNOTATIONS:
return getEAnnotations();
case UML2Package.INTERACTION_CONSTRAINT__OWNED_ELEMENT:
return getOwnedElements();
case UML2Package.INTERACTION_CONSTRAINT__OWNER:
if (resolve) return getOwner();
return basicGetOwner();
case UML2Package.INTERACTION_CONSTRAINT__OWNED_COMMENT:
return getOwnedComments();
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_BINDING:
return getTemplateBindings();
case UML2Package.INTERACTION_CONSTRAINT__OWNED_TEMPLATE_SIGNATURE:
return getOwnedTemplateSignature();
case UML2Package.INTERACTION_CONSTRAINT__NAME:
return getName();
case UML2Package.INTERACTION_CONSTRAINT__QUALIFIED_NAME:
return getQualifiedName();
case UML2Package.INTERACTION_CONSTRAINT__VISIBILITY:
return getVisibility();
case UML2Package.INTERACTION_CONSTRAINT__CLIENT_DEPENDENCY:
return getClientDependencies();
case UML2Package.INTERACTION_CONSTRAINT__NAME_EXPRESSION:
return getNameExpression();
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_PARAMETER:
if (resolve) return getTemplateParameter();
return basicGetTemplateParameter();
case UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER:
return getOwningParameter();
case UML2Package.INTERACTION_CONSTRAINT__PACKAGEABLE_ELEMENT_VISIBILITY:
return getPackageableElement_visibility();
case UML2Package.INTERACTION_CONSTRAINT__CONTEXT:
if (resolve) return getContext();
return basicGetContext();
case UML2Package.INTERACTION_CONSTRAINT__NAMESPACE:
return getNamespace();
case UML2Package.INTERACTION_CONSTRAINT__SPECIFICATION:
return getSpecification();
case UML2Package.INTERACTION_CONSTRAINT__CONSTRAINED_ELEMENT:
return getConstrainedElements();
case UML2Package.INTERACTION_CONSTRAINT__MININT:
return getMinint();
case UML2Package.INTERACTION_CONSTRAINT__MAXINT:
return getMaxint();
}
return eDynamicGet(eFeature, resolve);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(EStructuralFeature eFeature, Object newValue) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UML2Package.INTERACTION_CONSTRAINT__EANNOTATIONS:
getEAnnotations().clear();
getEAnnotations().addAll((Collection)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__OWNED_COMMENT:
getOwnedComments().clear();
getOwnedComments().addAll((Collection)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_BINDING:
getTemplateBindings().clear();
getTemplateBindings().addAll((Collection)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__OWNED_TEMPLATE_SIGNATURE:
setOwnedTemplateSignature((TemplateSignature)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__NAME:
setName((String)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__VISIBILITY:
setVisibility((VisibilityKind)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__CLIENT_DEPENDENCY:
getClientDependencies().clear();
getClientDependencies().addAll((Collection)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__NAME_EXPRESSION:
setNameExpression((StringExpression)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_PARAMETER:
setTemplateParameter((TemplateParameter)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER:
setOwningParameter((TemplateParameter)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__PACKAGEABLE_ELEMENT_VISIBILITY:
setPackageableElement_visibility((VisibilityKind)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__NAMESPACE:
setNamespace((Namespace)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__SPECIFICATION:
setSpecification((ValueSpecification)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__CONSTRAINED_ELEMENT:
getConstrainedElements().clear();
getConstrainedElements().addAll((Collection)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__MININT:
setMinint((ValueSpecification)newValue);
return;
case UML2Package.INTERACTION_CONSTRAINT__MAXINT:
setMaxint((ValueSpecification)newValue);
return;
}
eDynamicSet(eFeature, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UML2Package.INTERACTION_CONSTRAINT__EANNOTATIONS:
getEAnnotations().clear();
return;
case UML2Package.INTERACTION_CONSTRAINT__OWNED_COMMENT:
getOwnedComments().clear();
return;
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_BINDING:
getTemplateBindings().clear();
return;
case UML2Package.INTERACTION_CONSTRAINT__OWNED_TEMPLATE_SIGNATURE:
setOwnedTemplateSignature((TemplateSignature)null);
return;
case UML2Package.INTERACTION_CONSTRAINT__NAME:
setName(NAME_EDEFAULT);
return;
case UML2Package.INTERACTION_CONSTRAINT__VISIBILITY:
setVisibility(VISIBILITY_EDEFAULT);
return;
case UML2Package.INTERACTION_CONSTRAINT__CLIENT_DEPENDENCY:
getClientDependencies().clear();
return;
case UML2Package.INTERACTION_CONSTRAINT__NAME_EXPRESSION:
setNameExpression((StringExpression)null);
return;
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_PARAMETER:
setTemplateParameter((TemplateParameter)null);
return;
case UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER:
setOwningParameter(null);
return;
case UML2Package.INTERACTION_CONSTRAINT__PACKAGEABLE_ELEMENT_VISIBILITY:
setPackageableElement_visibility(PACKAGEABLE_ELEMENT_VISIBILITY_EDEFAULT);
return;
case UML2Package.INTERACTION_CONSTRAINT__NAMESPACE:
setNamespace(null);
return;
case UML2Package.INTERACTION_CONSTRAINT__SPECIFICATION:
setSpecification((ValueSpecification)null);
return;
case UML2Package.INTERACTION_CONSTRAINT__CONSTRAINED_ELEMENT:
getConstrainedElements().clear();
return;
case UML2Package.INTERACTION_CONSTRAINT__MININT:
setMinint((ValueSpecification)null);
return;
case UML2Package.INTERACTION_CONSTRAINT__MAXINT:
setMaxint((ValueSpecification)null);
return;
}
eDynamicUnset(eFeature);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UML2Package.INTERACTION_CONSTRAINT__EANNOTATIONS:
return eAnnotations != null && !eAnnotations.isEmpty();
case UML2Package.INTERACTION_CONSTRAINT__OWNED_ELEMENT:
return !getOwnedElements().isEmpty();
case UML2Package.INTERACTION_CONSTRAINT__OWNER:
return basicGetOwner() != null;
case UML2Package.INTERACTION_CONSTRAINT__OWNED_COMMENT:
return ownedComment != null && !ownedComment.isEmpty();
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_BINDING:
return templateBinding != null && !templateBinding.isEmpty();
case UML2Package.INTERACTION_CONSTRAINT__OWNED_TEMPLATE_SIGNATURE:
return ownedTemplateSignature != null;
case UML2Package.INTERACTION_CONSTRAINT__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case UML2Package.INTERACTION_CONSTRAINT__QUALIFIED_NAME:
return !"".equals(getQualifiedName()); //$NON-NLS-1$
case UML2Package.INTERACTION_CONSTRAINT__VISIBILITY:
return visibility != VISIBILITY_EDEFAULT;
case UML2Package.INTERACTION_CONSTRAINT__CLIENT_DEPENDENCY:
return clientDependency != null && !clientDependency.isEmpty();
case UML2Package.INTERACTION_CONSTRAINT__NAME_EXPRESSION:
return nameExpression != null;
case UML2Package.INTERACTION_CONSTRAINT__TEMPLATE_PARAMETER:
return templateParameter != null;
case UML2Package.INTERACTION_CONSTRAINT__OWNING_PARAMETER:
return getOwningParameter() != null;
case UML2Package.INTERACTION_CONSTRAINT__PACKAGEABLE_ELEMENT_VISIBILITY:
return packageableElement_visibility != PACKAGEABLE_ELEMENT_VISIBILITY_EDEFAULT;
case UML2Package.INTERACTION_CONSTRAINT__CONTEXT:
return basicGetContext() != null;
case UML2Package.INTERACTION_CONSTRAINT__NAMESPACE:
return getNamespace() != null;
case UML2Package.INTERACTION_CONSTRAINT__SPECIFICATION:
return specification != null;
case UML2Package.INTERACTION_CONSTRAINT__CONSTRAINED_ELEMENT:
return constrainedElement != null && !constrainedElement.isEmpty();
case UML2Package.INTERACTION_CONSTRAINT__MININT:
return minint != null;
case UML2Package.INTERACTION_CONSTRAINT__MAXINT:
return maxint != null;
}
return eDynamicIsSet(eFeature);
}
} //InteractionConstraintImpl