| /* |
| * Copyright (c) 2003, 2005 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: TemplateableElementImpl.java,v 1.14 2005/11/09 22:53:07 khussey Exp $ |
| */ |
| package org.eclipse.uml2.impl; |
| |
| import java.util.Collection; |
| 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.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.uml2.Element; |
| import org.eclipse.uml2.TemplateBinding; |
| import org.eclipse.uml2.TemplateSignature; |
| import org.eclipse.uml2.TemplateableElement; |
| import org.eclipse.uml2.UML2Factory; |
| import org.eclipse.uml2.UML2Package; |
| |
| import org.eclipse.uml2.common.util.CacheAdapter; |
| |
| import org.eclipse.uml2.common.util.DerivedUnionEObjectEList; |
| |
| import org.eclipse.uml2.internal.operation.TemplateableElementOperations; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Templateable Element</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.uml2.impl.TemplateableElementImpl#getOwnedElements <em>Owned Element</em>}</li> |
| * <li>{@link org.eclipse.uml2.impl.TemplateableElementImpl#getTemplateBindings <em>Template Binding</em>}</li> |
| * <li>{@link org.eclipse.uml2.impl.TemplateableElementImpl#getOwnedTemplateSignature <em>Owned Template Signature</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public abstract class TemplateableElementImpl extends ElementImpl implements TemplateableElement { |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static final String copyright = "Copyright (c) IBM Corporation and others."; //$NON-NLS-1$ |
| |
| /** |
| * The cached value of the '{@link #getTemplateBindings() <em>Template Binding</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTemplateBindings() |
| * @generated |
| * @ordered |
| */ |
| protected EList templateBinding = null; |
| |
| /** |
| * The cached value of the '{@link #getOwnedTemplateSignature() <em>Owned Template Signature</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedTemplateSignature() |
| * @generated |
| * @ordered |
| */ |
| protected TemplateSignature ownedTemplateSignature = null; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected TemplateableElementImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EClass eStaticClass() { |
| return UML2Package.eINSTANCE.getTemplateableElement(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList getOwnedElements() { |
| if (ownedElement == null) { |
| ownedElement = new DerivedUnionEObjectEList(Element.class, this, UML2Package.TEMPLATEABLE_ELEMENT__OWNED_ELEMENT, new EStructuralFeature[] {UML2Package.eINSTANCE.getElement_OwnedComment(), UML2Package.eINSTANCE.getTemplateableElement_TemplateBinding(), UML2Package.eINSTANCE.getTemplateableElement_OwnedTemplateSignature()}); |
| } |
| return ownedElement; |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSetOwnedElements() { |
| return super.isSetOwnedElements() |
| || eIsSet(UML2Package.eINSTANCE.getTemplateableElement_TemplateBinding()) |
| || eIsSet(UML2Package.eINSTANCE.getTemplateableElement_OwnedTemplateSignature()); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList getTemplateBindings() { |
| if (templateBinding == null) { |
| templateBinding = new EObjectContainmentWithInverseEList(TemplateBinding.class, this, UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING, UML2Package.TEMPLATE_BINDING__BOUND_ELEMENT); |
| } |
| return templateBinding; |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| * @deprecated Use #createTemplateBinding() instead. |
| */ |
| public TemplateBinding createTemplateBinding(EClass eClass) { |
| TemplateBinding newTemplateBinding = (TemplateBinding) eClass.getEPackage().getEFactoryInstance().create(eClass); |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, 0, UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING, null, newTemplateBinding)); |
| } |
| getTemplateBindings().add(newTemplateBinding); |
| return newTemplateBinding; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TemplateBinding createTemplateBinding() { |
| TemplateBinding newTemplateBinding = UML2Factory.eINSTANCE.createTemplateBinding(); |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, 0, UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING, null, newTemplateBinding)); |
| } |
| getTemplateBindings().add(newTemplateBinding); |
| return newTemplateBinding; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TemplateSignature getOwnedTemplateSignature() { |
| return ownedTemplateSignature; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedTemplateSignature(TemplateSignature newOwnedTemplateSignature, NotificationChain msgs) { |
| TemplateSignature oldOwnedTemplateSignature = ownedTemplateSignature; |
| ownedTemplateSignature = newOwnedTemplateSignature; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE, oldOwnedTemplateSignature, newOwnedTemplateSignature); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setOwnedTemplateSignature(TemplateSignature newOwnedTemplateSignature) { |
| if (newOwnedTemplateSignature != ownedTemplateSignature) { |
| NotificationChain msgs = null; |
| if (ownedTemplateSignature != null) |
| msgs = ((InternalEObject)ownedTemplateSignature).eInverseRemove(this, UML2Package.TEMPLATE_SIGNATURE__TEMPLATE, TemplateSignature.class, msgs); |
| if (newOwnedTemplateSignature != null) |
| msgs = ((InternalEObject)newOwnedTemplateSignature).eInverseAdd(this, UML2Package.TEMPLATE_SIGNATURE__TEMPLATE, TemplateSignature.class, msgs); |
| msgs = basicSetOwnedTemplateSignature(newOwnedTemplateSignature, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE, newOwnedTemplateSignature, newOwnedTemplateSignature)); |
| |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TemplateSignature createOwnedTemplateSignature(EClass eClass) { |
| TemplateSignature newOwnedTemplateSignature = (TemplateSignature) eClass.getEPackage().getEFactoryInstance().create(eClass); |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, 0, UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE, null, newOwnedTemplateSignature)); |
| } |
| setOwnedTemplateSignature(newOwnedTemplateSignature); |
| return newOwnedTemplateSignature; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TemplateSignature createOwnedTemplateSignature() { |
| TemplateSignature newOwnedTemplateSignature = UML2Factory.eINSTANCE.createTemplateSignature(); |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, 0, UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE, null, newOwnedTemplateSignature)); |
| } |
| setOwnedTemplateSignature(newOwnedTemplateSignature); |
| return newOwnedTemplateSignature; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Set parameterableElements() { |
| CacheAdapter cache = getCacheAdapter(); |
| if (cache != null) { |
| Set result = (Set) cache.get(eResource(), this, UML2Package.eINSTANCE.getTemplateableElement().getEOperations().get(0)); |
| if (result == null) { |
| cache.put(eResource(), this, UML2Package.eINSTANCE.getTemplateableElement().getEOperations().get(0), result = TemplateableElementOperations.parameterableElements(this)); |
| } |
| return result; |
| } |
| return TemplateableElementOperations.parameterableElements(this); |
| } |
| |
| /** |
| * <!-- 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.TEMPLATEABLE_ELEMENT__EANNOTATIONS: |
| return ((InternalEList)getEAnnotations()).basicAdd(otherEnd, msgs); |
| case UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING: |
| return ((InternalEList)getTemplateBindings()).basicAdd(otherEnd, msgs); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| if (ownedTemplateSignature != null) |
| msgs = ((InternalEObject)ownedTemplateSignature).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE, null, msgs); |
| return basicSetOwnedTemplateSignature((TemplateSignature)otherEnd, 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.TEMPLATEABLE_ELEMENT__EANNOTATIONS: |
| return ((InternalEList)getEAnnotations()).basicRemove(otherEnd, msgs); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_COMMENT: |
| return ((InternalEList)getOwnedComments()).basicRemove(otherEnd, msgs); |
| case UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING: |
| return ((InternalEList)getTemplateBindings()).basicRemove(otherEnd, msgs); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| return basicSetOwnedTemplateSignature(null, msgs); |
| default: |
| return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); |
| } |
| } |
| return eBasicSetContainer(null, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object eGet(EStructuralFeature eFeature, boolean resolve) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.TEMPLATEABLE_ELEMENT__EANNOTATIONS: |
| return getEAnnotations(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_ELEMENT: |
| return getOwnedElements(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNER: |
| if (resolve) return getOwner(); |
| return basicGetOwner(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_COMMENT: |
| return getOwnedComments(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING: |
| return getTemplateBindings(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| return getOwnedTemplateSignature(); |
| } |
| return eDynamicGet(eFeature, resolve); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eSet(EStructuralFeature eFeature, Object newValue) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.TEMPLATEABLE_ELEMENT__EANNOTATIONS: |
| getEAnnotations().clear(); |
| getEAnnotations().addAll((Collection)newValue); |
| return; |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_COMMENT: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection)newValue); |
| return; |
| case UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING: |
| getTemplateBindings().clear(); |
| getTemplateBindings().addAll((Collection)newValue); |
| return; |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| setOwnedTemplateSignature((TemplateSignature)newValue); |
| return; |
| } |
| eDynamicSet(eFeature, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eUnset(EStructuralFeature eFeature) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.TEMPLATEABLE_ELEMENT__EANNOTATIONS: |
| getEAnnotations().clear(); |
| return; |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_COMMENT: |
| getOwnedComments().clear(); |
| return; |
| case UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING: |
| getTemplateBindings().clear(); |
| return; |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| setOwnedTemplateSignature((TemplateSignature)null); |
| return; |
| } |
| eDynamicUnset(eFeature); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean eIsSet(EStructuralFeature eFeature) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.TEMPLATEABLE_ELEMENT__EANNOTATIONS: |
| return eAnnotations != null && !eAnnotations.isEmpty(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_ELEMENT: |
| return isSetOwnedElements(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNER: |
| return isSetOwner(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_COMMENT: |
| return ownedComment != null && !ownedComment.isEmpty(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__TEMPLATE_BINDING: |
| return templateBinding != null && !templateBinding.isEmpty(); |
| case UML2Package.TEMPLATEABLE_ELEMENT__OWNED_TEMPLATE_SIGNATURE: |
| return ownedTemplateSignature != null; |
| } |
| return eDynamicIsSet(eFeature); |
| } |
| |
| |
| } //TemplateableElementImpl |