blob: bb60d12ea87688b9d482e32c0d098454f1986869 [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: ParameterableElementImpl.java,v 1.5.2.1 2004/09/07 20:00:13 khussey Exp $
*/
package org.eclipse.uml2.impl;
import java.util.Collection;
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.EObject;
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.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.uml2.Element;
import org.eclipse.uml2.ParameterableElement;
import org.eclipse.uml2.TemplateParameter;
import org.eclipse.uml2.UML2Package;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Parameterable Element</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.uml2.impl.ParameterableElementImpl#getTemplateParameter <em>Template Parameter</em>}</li>
* <li>{@link org.eclipse.uml2.impl.ParameterableElementImpl#getOwningParameter <em>Owning Parameter</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public abstract class ParameterableElementImpl extends ElementImpl implements ParameterableElement {
/**
* <!-- 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 #getTemplateParameter() <em>Template Parameter</em>}' reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getTemplateParameter()
* @generated
* @ordered
*/
protected TemplateParameter templateParameter = null;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ParameterableElementImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return UML2Package.eINSTANCE.getParameterableElement();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TemplateParameter getTemplateParameter() {
if (templateParameter != null && templateParameter.eIsProxy()) {
TemplateParameter oldTemplateParameter = templateParameter;
templateParameter = (TemplateParameter)eResolveProxy((InternalEObject)templateParameter);
if (templateParameter != oldTemplateParameter) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.RESOLVE, UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER, oldTemplateParameter, templateParameter));
}
}
return templateParameter;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TemplateParameter basicGetTemplateParameter() {
return templateParameter;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTemplateParameter(TemplateParameter newTemplateParameter, NotificationChain msgs) {
TemplateParameter oldTemplateParameter = templateParameter;
templateParameter = newTemplateParameter;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER, oldTemplateParameter, newTemplateParameter);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
if (null != getOwningParameter() && newTemplateParameter != getOwningParameter()) {
setOwningParameter(null);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTemplateParameter(TemplateParameter newTemplateParameter) {
if (newTemplateParameter != templateParameter) {
NotificationChain msgs = null;
if (null != templateParameter) {
msgs = ((InternalEObject) templateParameter).eInverseRemove(this, UML2Package.TEMPLATE_PARAMETER__PARAMETERED_ELEMENT, TemplateParameter.class, msgs);
}
if (null != newTemplateParameter) {
msgs = ((InternalEObject) newTemplateParameter).eInverseAdd(this, UML2Package.TEMPLATE_PARAMETER__PARAMETERED_ELEMENT, TemplateParameter.class, msgs);
}
msgs = basicSetTemplateParameter(newTemplateParameter, msgs);
if (null != msgs) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER, newTemplateParameter, newTemplateParameter));
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TemplateParameter getOwningParameter() {
if (eContainerFeatureID != UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER) {
return null;
}
return (TemplateParameter) eContainer;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOwningParameter(TemplateParameter newOwningParameter) {
EObject oldOwningParameter = eContainer;
if (eContainer != newOwningParameter || (eContainerFeatureID != UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER && null != newOwningParameter)) {
if (EcoreUtil.isAncestor(this, newOwningParameter)) {
throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$
}
NotificationChain msgs = null;
if (null != eContainer) {
msgs = eBasicRemoveFromContainer(msgs);
}
if (null != newOwningParameter) {
msgs = ((InternalEObject) newOwningParameter).eInverseAdd(this, UML2Package.TEMPLATE_PARAMETER__OWNED_PARAMETERED_ELEMENT, TemplateParameter.class, msgs);
}
msgs = eBasicSetContainer((InternalEObject) newOwningParameter, UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER, msgs);
if (null != msgs) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER, newOwningParameter, newOwningParameter));
}
if (null != newOwningParameter || oldOwningParameter == templateParameter) {
setTemplateParameter(newOwningParameter);
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Element basicGetOwner() {
if (null != getOwningParameter()) {
return (Element) getOwningParameter();
}
return super.basicGetOwner();
}
/**
* <!-- 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.PARAMETERABLE_ELEMENT__EANNOTATIONS:
return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs);
case UML2Package.PARAMETERABLE_ELEMENT__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.PARAMETERABLE_ELEMENT__OWNING_PARAMETER:
if (eContainer != null)
msgs = eBasicRemoveFromContainer(msgs);
return eBasicSetContainer(otherEnd, UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER, 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.PARAMETERABLE_ELEMENT__EANNOTATIONS:
return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs);
case UML2Package.PARAMETERABLE_ELEMENT__OWNED_COMMENT:
return ((InternalEList)getOwnedComments()).basicRemove(otherEnd, msgs);
case UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER:
return basicSetTemplateParameter(null, msgs);
case UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER:
return eBasicSetContainer(null, UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER, 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.PARAMETERABLE_ELEMENT__OWNING_PARAMETER:
return eContainer.eInverseRemove(this, UML2Package.TEMPLATE_PARAMETER__OWNED_PARAMETERED_ELEMENT, TemplateParameter.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.PARAMETERABLE_ELEMENT__EANNOTATIONS:
return getEAnnotations();
case UML2Package.PARAMETERABLE_ELEMENT__OWNED_ELEMENT:
return getOwnedElements();
case UML2Package.PARAMETERABLE_ELEMENT__OWNER:
if (resolve) return getOwner();
return basicGetOwner();
case UML2Package.PARAMETERABLE_ELEMENT__OWNED_COMMENT:
return getOwnedComments();
case UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER:
if (resolve) return getTemplateParameter();
return basicGetTemplateParameter();
case UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER:
return getOwningParameter();
}
return eDynamicGet(eFeature, resolve);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(EStructuralFeature eFeature, Object newValue) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UML2Package.PARAMETERABLE_ELEMENT__EANNOTATIONS:
getEAnnotations().clear();
getEAnnotations().addAll((Collection)newValue);
return;
case UML2Package.PARAMETERABLE_ELEMENT__OWNED_COMMENT:
getOwnedComments().clear();
getOwnedComments().addAll((Collection)newValue);
return;
case UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER:
setTemplateParameter((TemplateParameter)newValue);
return;
case UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER:
setOwningParameter((TemplateParameter)newValue);
return;
}
eDynamicSet(eFeature, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UML2Package.PARAMETERABLE_ELEMENT__EANNOTATIONS:
getEAnnotations().clear();
return;
case UML2Package.PARAMETERABLE_ELEMENT__OWNED_COMMENT:
getOwnedComments().clear();
return;
case UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER:
setTemplateParameter((TemplateParameter)null);
return;
case UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER:
setOwningParameter((TemplateParameter)null);
return;
}
eDynamicUnset(eFeature);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case UML2Package.PARAMETERABLE_ELEMENT__EANNOTATIONS:
return eAnnotations != null && !eAnnotations.isEmpty();
case UML2Package.PARAMETERABLE_ELEMENT__OWNED_ELEMENT:
return !getOwnedElements().isEmpty();
case UML2Package.PARAMETERABLE_ELEMENT__OWNER:
return basicGetOwner() != null;
case UML2Package.PARAMETERABLE_ELEMENT__OWNED_COMMENT:
return ownedComment != null && !ownedComment.isEmpty();
case UML2Package.PARAMETERABLE_ELEMENT__TEMPLATE_PARAMETER:
return templateParameter != null;
case UML2Package.PARAMETERABLE_ELEMENT__OWNING_PARAMETER:
return getOwningParameter() != null;
}
return eDynamicIsSet(eFeature);
}
} //ParameterableElementImpl