| /* |
| * Copyright (c) 2005, 2006 IBM Corporation 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: |
| * IBM - initial API and implementation |
| * |
| * $Id: DurationConstraintImpl.java,v 1.20 2006/12/14 15:49:31 khussey Exp $ |
| */ |
| package org.eclipse.uml2.uml.internal.impl; |
| |
| import java.util.Collection; |
| import java.util.Map; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| import org.eclipse.emf.common.util.EList; |
| |
| import org.eclipse.emf.ecore.EAnnotation; |
| 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.EDataTypeUniqueEList; |
| |
| import org.eclipse.uml2.uml.Comment; |
| import org.eclipse.uml2.uml.Dependency; |
| import org.eclipse.uml2.uml.DurationConstraint; |
| import org.eclipse.uml2.uml.Element; |
| import org.eclipse.uml2.uml.DurationInterval; |
| import org.eclipse.uml2.uml.Namespace; |
| import org.eclipse.uml2.uml.StringExpression; |
| import org.eclipse.uml2.uml.TemplateParameter; |
| import org.eclipse.uml2.uml.Type; |
| import org.eclipse.uml2.uml.UMLPackage; |
| import org.eclipse.uml2.uml.ValueSpecification; |
| |
| import org.eclipse.uml2.uml.VisibilityKind; |
| |
| import org.eclipse.uml2.uml.internal.operations.DurationConstraintOperations; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Duration Constraint</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.uml2.uml.internal.impl.DurationConstraintImpl#getFirstEvents <em>First Event</em>}</li> |
| * <li>{@link org.eclipse.uml2.uml.internal.impl.DurationConstraintImpl#getSpecification <em>Specification</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class DurationConstraintImpl |
| extends IntervalConstraintImpl |
| implements DurationConstraint { |
| |
| /** |
| * The cached value of the '{@link #getFirstEvents() <em>First Event</em>}' attribute list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFirstEvents() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Boolean> firstEvents = null; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DurationConstraintImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return UMLPackage.Literals.DURATION_CONSTRAINT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Boolean> getFirstEvents() { |
| if (firstEvents == null) { |
| firstEvents = new EDataTypeUniqueEList<Boolean>(Boolean.class, |
| this, UMLPackage.DURATION_CONSTRAINT__FIRST_EVENT); |
| } |
| return firstEvents; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ValueSpecification getSpecification() { |
| if (specification != null && specification.eIsProxy()) { |
| InternalEObject oldSpecification = (InternalEObject) specification; |
| specification = (ValueSpecification) eResolveProxy(oldSpecification); |
| if (specification != oldSpecification) { |
| InternalEObject newSpecification = (InternalEObject) specification; |
| NotificationChain msgs = oldSpecification.eInverseRemove(this, |
| EOPPOSITE_FEATURE_BASE |
| - UMLPackage.DURATION_CONSTRAINT__SPECIFICATION, null, |
| null); |
| if (newSpecification.eInternalContainer() == null) { |
| msgs = newSpecification.eInverseAdd(this, |
| EOPPOSITE_FEATURE_BASE |
| - UMLPackage.DURATION_CONSTRAINT__SPECIFICATION, |
| null, msgs); |
| } |
| if (msgs != null) |
| msgs.dispatch(); |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, |
| UMLPackage.DURATION_CONSTRAINT__SPECIFICATION, |
| oldSpecification, specification)); |
| } |
| } |
| return specification; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ValueSpecification basicGetSpecification() { |
| return specification; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetSpecificationGen( |
| ValueSpecification newSpecification, NotificationChain msgs) { |
| ValueSpecification oldSpecification = specification; |
| specification = newSpecification; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, |
| Notification.SET, |
| UMLPackage.DURATION_CONSTRAINT__SPECIFICATION, |
| oldSpecification, newSpecification); |
| if (msgs == null) |
| msgs = notification; |
| else |
| msgs.add(notification); |
| } |
| |
| return msgs; |
| } |
| |
| @Override |
| public NotificationChain basicSetSpecification( |
| ValueSpecification newSpecification, NotificationChain msgs) { |
| |
| if (newSpecification != null |
| && !(newSpecification instanceof DurationInterval)) { |
| |
| throw new IllegalArgumentException(newSpecification.toString()); |
| } |
| |
| return basicSetSpecificationGen(newSpecification, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setSpecification(ValueSpecification newSpecification) { |
| |
| if (newSpecification != specification) { |
| NotificationChain msgs = null; |
| if (specification != null) |
| msgs = ((InternalEObject) specification).eInverseRemove(this, |
| EOPPOSITE_FEATURE_BASE |
| - UMLPackage.DURATION_CONSTRAINT__SPECIFICATION, null, |
| msgs); |
| if (newSpecification != null) |
| msgs = ((InternalEObject) newSpecification).eInverseAdd(this, |
| EOPPOSITE_FEATURE_BASE |
| - UMLPackage.DURATION_CONSTRAINT__SPECIFICATION, null, |
| msgs); |
| msgs = basicSetSpecification(newSpecification, msgs); |
| if (msgs != null) |
| msgs.dispatch(); |
| } else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, |
| UMLPackage.DURATION_CONSTRAINT__SPECIFICATION, |
| newSpecification, newSpecification)); |
| |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public ValueSpecification createSpecification(String name, Type type, |
| EClass eClass) { |
| ValueSpecification newSpecification = (ValueSpecification) create(eClass); |
| setSpecification(newSpecification); |
| if (name != null) |
| newSpecification.setName(name); |
| if (type != null) |
| newSpecification.setType(type); |
| return newSpecification; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSetSpecification() { |
| return specification != null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean validateFirstEventMultiplicity(DiagnosticChain diagnostics, |
| Map<Object, Object> context) { |
| return DurationConstraintOperations.validateFirstEventMultiplicity( |
| this, diagnostics, context); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case UMLPackage.DURATION_CONSTRAINT__EANNOTATIONS : |
| return getEAnnotations(); |
| case UMLPackage.DURATION_CONSTRAINT__OWNED_ELEMENT : |
| return getOwnedElements(); |
| case UMLPackage.DURATION_CONSTRAINT__OWNER : |
| if (resolve) |
| return getOwner(); |
| return basicGetOwner(); |
| case UMLPackage.DURATION_CONSTRAINT__OWNED_COMMENT : |
| return getOwnedComments(); |
| case UMLPackage.DURATION_CONSTRAINT__NAME : |
| return getName(); |
| case UMLPackage.DURATION_CONSTRAINT__VISIBILITY : |
| return getVisibility(); |
| case UMLPackage.DURATION_CONSTRAINT__QUALIFIED_NAME : |
| return getQualifiedName(); |
| case UMLPackage.DURATION_CONSTRAINT__CLIENT_DEPENDENCY : |
| return getClientDependencies(); |
| case UMLPackage.DURATION_CONSTRAINT__NAMESPACE : |
| if (resolve) |
| return getNamespace(); |
| return basicGetNamespace(); |
| case UMLPackage.DURATION_CONSTRAINT__NAME_EXPRESSION : |
| if (resolve) |
| return getNameExpression(); |
| return basicGetNameExpression(); |
| case UMLPackage.DURATION_CONSTRAINT__OWNING_TEMPLATE_PARAMETER : |
| if (resolve) |
| return getOwningTemplateParameter(); |
| return basicGetOwningTemplateParameter(); |
| case UMLPackage.DURATION_CONSTRAINT__TEMPLATE_PARAMETER : |
| if (resolve) |
| return getTemplateParameter(); |
| return basicGetTemplateParameter(); |
| case UMLPackage.DURATION_CONSTRAINT__CONSTRAINED_ELEMENT : |
| return getConstrainedElements(); |
| case UMLPackage.DURATION_CONSTRAINT__SPECIFICATION : |
| if (resolve) |
| return getSpecification(); |
| return basicGetSpecification(); |
| case UMLPackage.DURATION_CONSTRAINT__CONTEXT : |
| if (resolve) |
| return getContext(); |
| return basicGetContext(); |
| case UMLPackage.DURATION_CONSTRAINT__FIRST_EVENT : |
| return getFirstEvents(); |
| } |
| 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 UMLPackage.DURATION_CONSTRAINT__EANNOTATIONS : |
| getEAnnotations().clear(); |
| getEAnnotations().addAll( |
| (Collection<? extends EAnnotation>) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__OWNED_COMMENT : |
| getOwnedComments().clear(); |
| getOwnedComments().addAll( |
| (Collection<? extends Comment>) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__NAME : |
| setName((String) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__VISIBILITY : |
| setVisibility((VisibilityKind) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__CLIENT_DEPENDENCY : |
| getClientDependencies().clear(); |
| getClientDependencies().addAll( |
| (Collection<? extends Dependency>) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__NAME_EXPRESSION : |
| setNameExpression((StringExpression) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__OWNING_TEMPLATE_PARAMETER : |
| setOwningTemplateParameter((TemplateParameter) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__TEMPLATE_PARAMETER : |
| setTemplateParameter((TemplateParameter) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__CONSTRAINED_ELEMENT : |
| getConstrainedElements().clear(); |
| getConstrainedElements().addAll( |
| (Collection<? extends Element>) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__SPECIFICATION : |
| setSpecification((ValueSpecification) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__CONTEXT : |
| setContext((Namespace) newValue); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__FIRST_EVENT : |
| getFirstEvents().clear(); |
| getFirstEvents().addAll( |
| (Collection<? extends Boolean>) newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case UMLPackage.DURATION_CONSTRAINT__EANNOTATIONS : |
| getEAnnotations().clear(); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__OWNED_COMMENT : |
| getOwnedComments().clear(); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__NAME : |
| unsetName(); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__VISIBILITY : |
| unsetVisibility(); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__CLIENT_DEPENDENCY : |
| getClientDependencies().clear(); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__NAME_EXPRESSION : |
| setNameExpression((StringExpression) null); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__OWNING_TEMPLATE_PARAMETER : |
| setOwningTemplateParameter((TemplateParameter) null); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__TEMPLATE_PARAMETER : |
| setTemplateParameter((TemplateParameter) null); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__CONSTRAINED_ELEMENT : |
| getConstrainedElements().clear(); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__SPECIFICATION : |
| setSpecification((ValueSpecification) null); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__CONTEXT : |
| setContext((Namespace) null); |
| return; |
| case UMLPackage.DURATION_CONSTRAINT__FIRST_EVENT : |
| getFirstEvents().clear(); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case UMLPackage.DURATION_CONSTRAINT__EANNOTATIONS : |
| return eAnnotations != null && !eAnnotations.isEmpty(); |
| case UMLPackage.DURATION_CONSTRAINT__OWNED_ELEMENT : |
| return isSetOwnedElements(); |
| case UMLPackage.DURATION_CONSTRAINT__OWNER : |
| return isSetOwner(); |
| case UMLPackage.DURATION_CONSTRAINT__OWNED_COMMENT : |
| return ownedComments != null && !ownedComments.isEmpty(); |
| case UMLPackage.DURATION_CONSTRAINT__NAME : |
| return isSetName(); |
| case UMLPackage.DURATION_CONSTRAINT__VISIBILITY : |
| return isSetVisibility(); |
| case UMLPackage.DURATION_CONSTRAINT__QUALIFIED_NAME : |
| return QUALIFIED_NAME_EDEFAULT == null |
| ? getQualifiedName() != null |
| : !QUALIFIED_NAME_EDEFAULT.equals(getQualifiedName()); |
| case UMLPackage.DURATION_CONSTRAINT__CLIENT_DEPENDENCY : |
| return clientDependencies != null |
| && !clientDependencies.isEmpty(); |
| case UMLPackage.DURATION_CONSTRAINT__NAMESPACE : |
| return isSetNamespace(); |
| case UMLPackage.DURATION_CONSTRAINT__NAME_EXPRESSION : |
| return nameExpression != null; |
| case UMLPackage.DURATION_CONSTRAINT__OWNING_TEMPLATE_PARAMETER : |
| return basicGetOwningTemplateParameter() != null; |
| case UMLPackage.DURATION_CONSTRAINT__TEMPLATE_PARAMETER : |
| return templateParameter != null; |
| case UMLPackage.DURATION_CONSTRAINT__CONSTRAINED_ELEMENT : |
| return constrainedElements != null |
| && !constrainedElements.isEmpty(); |
| case UMLPackage.DURATION_CONSTRAINT__SPECIFICATION : |
| return isSetSpecification(); |
| case UMLPackage.DURATION_CONSTRAINT__CONTEXT : |
| return basicGetContext() != null; |
| case UMLPackage.DURATION_CONSTRAINT__FIRST_EVENT : |
| return firstEvents != null && !firstEvents.isEmpty(); |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) |
| return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (firstEvent: "); //$NON-NLS-1$ |
| result.append(firstEvents); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //DurationConstraintImpl |