| /* |
| * 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: FeatureImpl.java,v 1.14 2005/11/09 22:53:08 khussey Exp $ |
| */ |
| package org.eclipse.uml2.impl; |
| |
| import java.util.Collection; |
| import java.util.Iterator; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| |
| import org.eclipse.emf.common.util.EList; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| import org.eclipse.uml2.Classifier; |
| import org.eclipse.uml2.Feature; |
| import org.eclipse.uml2.StringExpression; |
| import org.eclipse.uml2.TemplateSignature; |
| import org.eclipse.uml2.UML2Package; |
| import org.eclipse.uml2.VisibilityKind; |
| |
| import org.eclipse.uml2.common.util.DerivedUnionEObjectEList; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Feature</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.uml2.impl.FeatureImpl#getFeaturingClassifiers <em>Featuring Classifier</em>}</li> |
| * <li>{@link org.eclipse.uml2.impl.FeatureImpl#isStatic <em>Is Static</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public abstract class FeatureImpl extends RedefinableElementImpl implements Feature { |
| /** |
| * <!-- 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 #getFeaturingClassifiers() <em>Featuring Classifier</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFeaturingClassifiers() |
| * @generated |
| * @ordered |
| */ |
| protected EList featuringClassifier = null; |
| |
| /** |
| * The default value of the '{@link #isStatic() <em>Is Static</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isStatic() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean IS_STATIC_EDEFAULT = false; |
| |
| /** |
| * The flag representing the value of the '{@link #isStatic() <em>Is Static</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isStatic() |
| * @generated |
| * @ordered |
| */ |
| protected static final int IS_STATIC_EFLAG = 1 << 9; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected FeatureImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected EClass eStaticClass() { |
| return UML2Package.eINSTANCE.getFeature(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isStatic() { |
| return (eFlags & IS_STATIC_EFLAG) != 0; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setIsStatic(boolean newIsStatic) { |
| boolean oldIsStatic = (eFlags & IS_STATIC_EFLAG) != 0; |
| if (newIsStatic) eFlags |= IS_STATIC_EFLAG; else eFlags &= ~IS_STATIC_EFLAG; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UML2Package.FEATURE__IS_STATIC, oldIsStatic, newIsStatic)); |
| |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList getFeaturingClassifiers() { |
| if (featuringClassifier == null) { |
| featuringClassifier = new DerivedUnionEObjectEList(Classifier.class, this, UML2Package.FEATURE__FEATURING_CLASSIFIER, new EStructuralFeature[] {}); |
| } |
| return featuringClassifier; |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSetFeaturingClassifiers() { |
| return false; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Classifier getFeaturingClassifier(String name) { |
| for (Iterator i = getFeaturingClassifiers().iterator(); i.hasNext(); ) { |
| Classifier featuringClassifier = (Classifier) i.next(); |
| if (name.equals(featuringClassifier.getName())) { |
| return featuringClassifier; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Object eGet(EStructuralFeature eFeature, boolean resolve) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.FEATURE__EANNOTATIONS: |
| return getEAnnotations(); |
| case UML2Package.FEATURE__OWNED_ELEMENT: |
| return getOwnedElements(); |
| case UML2Package.FEATURE__OWNER: |
| if (resolve) return getOwner(); |
| return basicGetOwner(); |
| case UML2Package.FEATURE__OWNED_COMMENT: |
| return getOwnedComments(); |
| case UML2Package.FEATURE__TEMPLATE_BINDING: |
| return getTemplateBindings(); |
| case UML2Package.FEATURE__OWNED_TEMPLATE_SIGNATURE: |
| return getOwnedTemplateSignature(); |
| case UML2Package.FEATURE__NAME: |
| return getName(); |
| case UML2Package.FEATURE__QUALIFIED_NAME: |
| return getQualifiedName(); |
| case UML2Package.FEATURE__VISIBILITY: |
| return getVisibility(); |
| case UML2Package.FEATURE__CLIENT_DEPENDENCY: |
| return getClientDependencies(); |
| case UML2Package.FEATURE__NAME_EXPRESSION: |
| return getNameExpression(); |
| case UML2Package.FEATURE__REDEFINITION_CONTEXT: |
| return getRedefinitionContexts(); |
| case UML2Package.FEATURE__IS_LEAF: |
| return isLeaf() ? Boolean.TRUE : Boolean.FALSE; |
| case UML2Package.FEATURE__FEATURING_CLASSIFIER: |
| return getFeaturingClassifiers(); |
| case UML2Package.FEATURE__IS_STATIC: |
| return isStatic() ? Boolean.TRUE : Boolean.FALSE; |
| } |
| return eDynamicGet(eFeature, resolve); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eSet(EStructuralFeature eFeature, Object newValue) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.FEATURE__EANNOTATIONS: |
| getEAnnotations().clear(); |
| getEAnnotations().addAll((Collection)newValue); |
| return; |
| case UML2Package.FEATURE__OWNED_COMMENT: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection)newValue); |
| return; |
| case UML2Package.FEATURE__TEMPLATE_BINDING: |
| getTemplateBindings().clear(); |
| getTemplateBindings().addAll((Collection)newValue); |
| return; |
| case UML2Package.FEATURE__OWNED_TEMPLATE_SIGNATURE: |
| setOwnedTemplateSignature((TemplateSignature)newValue); |
| return; |
| case UML2Package.FEATURE__NAME: |
| setName((String)newValue); |
| return; |
| case UML2Package.FEATURE__VISIBILITY: |
| setVisibility((VisibilityKind)newValue); |
| return; |
| case UML2Package.FEATURE__CLIENT_DEPENDENCY: |
| getClientDependencies().clear(); |
| getClientDependencies().addAll((Collection)newValue); |
| return; |
| case UML2Package.FEATURE__NAME_EXPRESSION: |
| setNameExpression((StringExpression)newValue); |
| return; |
| case UML2Package.FEATURE__IS_LEAF: |
| setIsLeaf(((Boolean)newValue).booleanValue()); |
| return; |
| case UML2Package.FEATURE__IS_STATIC: |
| setIsStatic(((Boolean)newValue).booleanValue()); |
| return; |
| } |
| eDynamicSet(eFeature, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void eUnset(EStructuralFeature eFeature) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.FEATURE__EANNOTATIONS: |
| getEAnnotations().clear(); |
| return; |
| case UML2Package.FEATURE__OWNED_COMMENT: |
| getOwnedComments().clear(); |
| return; |
| case UML2Package.FEATURE__TEMPLATE_BINDING: |
| getTemplateBindings().clear(); |
| return; |
| case UML2Package.FEATURE__OWNED_TEMPLATE_SIGNATURE: |
| setOwnedTemplateSignature((TemplateSignature)null); |
| return; |
| case UML2Package.FEATURE__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case UML2Package.FEATURE__VISIBILITY: |
| setVisibility(VISIBILITY_EDEFAULT); |
| return; |
| case UML2Package.FEATURE__CLIENT_DEPENDENCY: |
| getClientDependencies().clear(); |
| return; |
| case UML2Package.FEATURE__NAME_EXPRESSION: |
| setNameExpression((StringExpression)null); |
| return; |
| case UML2Package.FEATURE__IS_LEAF: |
| setIsLeaf(IS_LEAF_EDEFAULT); |
| return; |
| case UML2Package.FEATURE__IS_STATIC: |
| setIsStatic(IS_STATIC_EDEFAULT); |
| return; |
| } |
| eDynamicUnset(eFeature); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean eIsSet(EStructuralFeature eFeature) { |
| switch (eDerivedStructuralFeatureID(eFeature)) { |
| case UML2Package.FEATURE__EANNOTATIONS: |
| return eAnnotations != null && !eAnnotations.isEmpty(); |
| case UML2Package.FEATURE__OWNED_ELEMENT: |
| return isSetOwnedElements(); |
| case UML2Package.FEATURE__OWNER: |
| return isSetOwner(); |
| case UML2Package.FEATURE__OWNED_COMMENT: |
| return ownedComment != null && !ownedComment.isEmpty(); |
| case UML2Package.FEATURE__TEMPLATE_BINDING: |
| return templateBinding != null && !templateBinding.isEmpty(); |
| case UML2Package.FEATURE__OWNED_TEMPLATE_SIGNATURE: |
| return ownedTemplateSignature != null; |
| case UML2Package.FEATURE__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case UML2Package.FEATURE__QUALIFIED_NAME: |
| return QUALIFIED_NAME_EDEFAULT == null ? getQualifiedName() != null : !QUALIFIED_NAME_EDEFAULT.equals(getQualifiedName()); |
| case UML2Package.FEATURE__VISIBILITY: |
| return visibility != VISIBILITY_EDEFAULT; |
| case UML2Package.FEATURE__CLIENT_DEPENDENCY: |
| return clientDependency != null && !clientDependency.isEmpty(); |
| case UML2Package.FEATURE__NAME_EXPRESSION: |
| return nameExpression != null; |
| case UML2Package.FEATURE__REDEFINITION_CONTEXT: |
| return isSetRedefinitionContexts(); |
| case UML2Package.FEATURE__IS_LEAF: |
| return ((eFlags & IS_LEAF_EFLAG) != 0) != IS_LEAF_EDEFAULT; |
| case UML2Package.FEATURE__FEATURING_CLASSIFIER: |
| return isSetFeaturingClassifiers(); |
| case UML2Package.FEATURE__IS_STATIC: |
| return ((eFlags & IS_STATIC_EFLAG) != 0) != IS_STATIC_EDEFAULT; |
| } |
| return eDynamicIsSet(eFeature); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (isStatic: "); //$NON-NLS-1$ |
| result.append((eFlags & IS_STATIC_EFLAG) != 0); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| protected EList getFeaturingClassifiersHelper(EList featuringClassifier) { |
| if (eContainer instanceof Classifier) { |
| featuringClassifier.add(eContainer); |
| } |
| return featuringClassifier; |
| } |
| |
| } //FeatureImpl |