| /* |
| * Copyright (c) 2005, 2011 IBM Corporation, CEA, 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 |
| * Kenn Hussey (CEA) - 327039 |
| * |
| * $Id: IntervalConstraintImpl.java,v 1.21 2007/04/25 17:47:02 khussey Exp $ |
| */ |
| package org.eclipse.uml2.uml.internal.impl; |
| |
| 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.uml2.uml.Interval; |
| import org.eclipse.uml2.uml.IntervalConstraint; |
| import org.eclipse.uml2.uml.Type; |
| import org.eclipse.uml2.uml.UMLPackage; |
| import org.eclipse.uml2.uml.ValueSpecification; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Interval Constraint</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.uml2.uml.internal.impl.IntervalConstraintImpl#getSpecification <em>Specification</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class IntervalConstraintImpl |
| extends ConstraintImpl |
| implements IntervalConstraint { |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected IntervalConstraintImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return UMLPackage.Literals.INTERVAL_CONSTRAINT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| 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.INTERVAL_CONSTRAINT__SPECIFICATION, null, |
| null); |
| if (newSpecification.eInternalContainer() == null) { |
| msgs = newSpecification.eInverseAdd(this, |
| EOPPOSITE_FEATURE_BASE |
| - UMLPackage.INTERVAL_CONSTRAINT__SPECIFICATION, |
| null, msgs); |
| } |
| if (msgs != null) |
| msgs.dispatch(); |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, |
| UMLPackage.INTERVAL_CONSTRAINT__SPECIFICATION, |
| oldSpecification, specification)); |
| } |
| } |
| return specification; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| 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.INTERVAL_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 Interval)) { |
| throw new IllegalArgumentException(newSpecification.toString()); |
| } |
| |
| return basicSetSpecificationGen(newSpecification, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setSpecification(ValueSpecification newSpecification) { |
| if (newSpecification != specification) { |
| NotificationChain msgs = null; |
| if (specification != null) |
| msgs = ((InternalEObject) specification).eInverseRemove(this, |
| EOPPOSITE_FEATURE_BASE |
| - UMLPackage.INTERVAL_CONSTRAINT__SPECIFICATION, null, |
| msgs); |
| if (newSpecification != null) |
| msgs = ((InternalEObject) newSpecification).eInverseAdd(this, |
| EOPPOSITE_FEATURE_BASE |
| - UMLPackage.INTERVAL_CONSTRAINT__SPECIFICATION, null, |
| msgs); |
| msgs = basicSetSpecification(newSpecification, msgs); |
| if (msgs != null) |
| msgs.dispatch(); |
| } else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, |
| UMLPackage.INTERVAL_CONSTRAINT__SPECIFICATION, |
| newSpecification, newSpecification)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| 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; |
| } |
| |
| } //IntervalConstraintImpl |