blob: 7f3bd92667359ac8a4270dadab591eabba9515d8 [file] [log] [blame]
/*
* 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: TemplateSignatureImpl.java,v 1.17 2006/11/14 18:02:16 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.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.uml2.common.util.CacheAdapter;
import org.eclipse.uml2.common.util.DerivedUnionEObjectEList;
import org.eclipse.uml2.common.util.SubsetSupersetEObjectContainmentWithInverseEList;
import org.eclipse.uml2.common.util.SubsetSupersetEObjectResolvingEList;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.TemplateParameter;
import org.eclipse.uml2.uml.TemplateSignature;
import org.eclipse.uml2.uml.TemplateableElement;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.internal.operations.TemplateSignatureOperations;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Template Signature</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TemplateSignatureImpl#getOwnedElements <em>Owned Element</em>}</li>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TemplateSignatureImpl#getOwner <em>Owner</em>}</li>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TemplateSignatureImpl#getParameters <em>Parameter</em>}</li>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TemplateSignatureImpl#getOwnedParameters <em>Owned Parameter</em>}</li>
* <li>{@link org.eclipse.uml2.uml.internal.impl.TemplateSignatureImpl#getTemplate <em>Template</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class TemplateSignatureImpl
extends ElementImpl
implements TemplateSignature {
/**
* The cached value of the '{@link #getParameters() <em>Parameter</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParameters()
* @generated
* @ordered
*/
protected EList parameters = null;
/**
* The cached value of the '{@link #getOwnedParameters() <em>Owned Parameter</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedParameters()
* @generated
* @ordered
*/
protected EList ownedParameters = null;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TemplateSignatureImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return UMLPackage.Literals.TEMPLATE_SIGNATURE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getOwnedElements() {
CacheAdapter cache = getCacheAdapter();
if (cache != null) {
Resource eResource = eResource();
EList ownedElements = (EList) cache.get(eResource, this,
UMLPackage.Literals.ELEMENT__OWNED_ELEMENT);
if (ownedElements == null) {
cache.put(eResource, this,
UMLPackage.Literals.ELEMENT__OWNED_ELEMENT,
ownedElements = new DerivedUnionEObjectEList(Element.class,
this, UMLPackage.TEMPLATE_SIGNATURE__OWNED_ELEMENT,
OWNED_ELEMENT_ESUBSETS));
}
return ownedElements;
}
return new DerivedUnionEObjectEList(Element.class, this,
UMLPackage.TEMPLATE_SIGNATURE__OWNED_ELEMENT,
OWNED_ELEMENT_ESUBSETS);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getParameters() {
if (parameters == null) {
parameters = new SubsetSupersetEObjectResolvingEList(
TemplateParameter.class, this,
UMLPackage.TEMPLATE_SIGNATURE__PARAMETER, null,
PARAMETER_ESUBSETS);
}
return parameters;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TemplateableElement getTemplate() {
if (eContainerFeatureID != UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE)
return null;
return (TemplateableElement) eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TemplateableElement basicGetTemplate() {
if (eContainerFeatureID != UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE)
return null;
return (TemplateableElement) eInternalContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTemplate(TemplateableElement newTemplate,
NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject) newTemplate,
UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setTemplate(TemplateableElement newTemplate) {
if (newTemplate != eInternalContainer()
|| (eContainerFeatureID != UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE && newTemplate != null)) {
if (EcoreUtil.isAncestor(this, newTemplate))
throw new IllegalArgumentException(
"Recursive containment not allowed for " + toString()); //$NON-NLS-1$
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newTemplate != null)
msgs = ((InternalEObject) newTemplate).eInverseAdd(this,
UMLPackage.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE,
TemplateableElement.class, msgs);
msgs = basicSetTemplate(newTemplate, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE, newTemplate,
newTemplate));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList getOwnedParameters() {
if (ownedParameters == null) {
ownedParameters = new SubsetSupersetEObjectContainmentWithInverseEList.Resolving(
TemplateParameter.class, this,
UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER,
OWNED_PARAMETER_ESUPERSETS, null,
UMLPackage.TEMPLATE_PARAMETER__SIGNATURE);
}
return ownedParameters;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TemplateParameter createOwnedParameter(EClass eClass) {
TemplateParameter newOwnedParameter = (TemplateParameter) create(eClass);
getOwnedParameters().add(newOwnedParameter);
return newOwnedParameter;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TemplateParameter createOwnedParameter() {
return createOwnedParameter(UMLPackage.Literals.TEMPLATE_PARAMETER);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean validateOwnElements(DiagnosticChain diagnostics, Map context) {
return TemplateSignatureOperations.validateOwnElements(this,
diagnostics, context);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseAdd(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case UMLPackage.TEMPLATE_SIGNATURE__EANNOTATIONS :
return ((InternalEList) getEAnnotations()).basicAdd(otherEnd,
msgs);
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER :
return ((InternalEList) getOwnedParameters()).basicAdd(
otherEnd, msgs);
case UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE :
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetTemplate((TemplateableElement) otherEnd, msgs);
}
return eDynamicInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case UMLPackage.TEMPLATE_SIGNATURE__EANNOTATIONS :
return ((InternalEList) getEAnnotations()).basicRemove(
otherEnd, msgs);
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_COMMENT :
return ((InternalEList) getOwnedComments()).basicRemove(
otherEnd, msgs);
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER :
return ((InternalEList) getOwnedParameters()).basicRemove(
otherEnd, msgs);
case UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE :
return basicSetTemplate(null, msgs);
}
return eDynamicInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eBasicRemoveFromContainerFeature(
NotificationChain msgs) {
switch (eContainerFeatureID) {
case UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE :
return eInternalContainer().eInverseRemove(this,
UMLPackage.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE,
TemplateableElement.class, msgs);
}
return eDynamicBasicRemoveFromContainer(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case UMLPackage.TEMPLATE_SIGNATURE__EANNOTATIONS :
return getEAnnotations();
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_ELEMENT :
return getOwnedElements();
case UMLPackage.TEMPLATE_SIGNATURE__OWNER :
if (resolve)
return getOwner();
return basicGetOwner();
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_COMMENT :
return getOwnedComments();
case UMLPackage.TEMPLATE_SIGNATURE__PARAMETER :
return getParameters();
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER :
return getOwnedParameters();
case UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE :
if (resolve)
return getTemplate();
return basicGetTemplate();
}
return eDynamicGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case UMLPackage.TEMPLATE_SIGNATURE__EANNOTATIONS :
getEAnnotations().clear();
getEAnnotations().addAll((Collection) newValue);
return;
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_COMMENT :
getOwnedComments().clear();
getOwnedComments().addAll((Collection) newValue);
return;
case UMLPackage.TEMPLATE_SIGNATURE__PARAMETER :
getParameters().clear();
getParameters().addAll((Collection) newValue);
return;
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER :
getOwnedParameters().clear();
getOwnedParameters().addAll((Collection) newValue);
return;
case UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE :
setTemplate((TemplateableElement) newValue);
return;
}
eDynamicSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID) {
case UMLPackage.TEMPLATE_SIGNATURE__EANNOTATIONS :
getEAnnotations().clear();
return;
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_COMMENT :
getOwnedComments().clear();
return;
case UMLPackage.TEMPLATE_SIGNATURE__PARAMETER :
getParameters().clear();
return;
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER :
getOwnedParameters().clear();
return;
case UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE :
setTemplate((TemplateableElement) null);
return;
}
eDynamicUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
case UMLPackage.TEMPLATE_SIGNATURE__EANNOTATIONS :
return eAnnotations != null && !eAnnotations.isEmpty();
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_ELEMENT :
return isSetOwnedElements();
case UMLPackage.TEMPLATE_SIGNATURE__OWNER :
return isSetOwner();
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_COMMENT :
return ownedComments != null && !ownedComments.isEmpty();
case UMLPackage.TEMPLATE_SIGNATURE__PARAMETER :
return parameters != null && !parameters.isEmpty();
case UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER :
return ownedParameters != null && !ownedParameters.isEmpty();
case UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE :
return basicGetTemplate() != null;
}
return eDynamicIsSet(featureID);
}
/**
* The array of subset feature identifiers for the '{@link #getOwnedElements() <em>Owned Element</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedElements()
* @generated
* @ordered
*/
protected static final int[] OWNED_ELEMENT_ESUBSETS = new int[]{
UMLPackage.TEMPLATE_SIGNATURE__OWNED_COMMENT,
UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER};
/**
* The array of subset feature identifiers for the '{@link #getParameters() <em>Parameter</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getParameters()
* @generated
* @ordered
*/
protected static final int[] PARAMETER_ESUBSETS = new int[]{UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER};
/**
* The array of superset feature identifiers for the '{@link #getOwnedParameters() <em>Owned Parameter</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedParameters()
* @generated
* @ordered
*/
protected static final int[] OWNED_PARAMETER_ESUPERSETS = new int[]{UMLPackage.TEMPLATE_SIGNATURE__PARAMETER};
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Element getOwner() {
Element owner = basicGetOwner();
return owner != null && owner.eIsProxy()
? (Element) eResolveProxy((InternalEObject) owner)
: owner;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Element basicGetOwner() {
TemplateableElement template = basicGetTemplate();
if (template != null) {
return template;
}
return super.basicGetOwner();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isSetOwner() {
return super.isSetOwner()
|| eIsSet(UMLPackage.TEMPLATE_SIGNATURE__TEMPLATE);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean isSetOwnedElements() {
return super.isSetOwnedElements()
|| eIsSet(UMLPackage.TEMPLATE_SIGNATURE__OWNED_PARAMETER);
}
} //TemplateSignatureImpl