| /******************************************************************************* |
| * Copyright (c) 2013, 2019 Willink Transformations and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * E.D.Willink - Initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ocl.pivot.internal; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.pivot.Comment; |
| import org.eclipse.ocl.pivot.Element; |
| import org.eclipse.ocl.pivot.ElementExtension; |
| import org.eclipse.ocl.pivot.Import; |
| import org.eclipse.ocl.pivot.Namespace; |
| import org.eclipse.ocl.pivot.PivotFactory; |
| import org.eclipse.ocl.pivot.PivotPackage; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Import</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ImportImpl#getImportedNamespace <em>Imported Namespace</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.ImportImpl#getXmiidVersion <em>Xmiid Version</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ImportImpl extends NamedElementImpl implements Import |
| { |
| /** |
| * The number of structural features of the '<em>Import</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int IMPORT_FEATURE_COUNT = NamedElementImpl.NAMED_ELEMENT_FEATURE_COUNT + 2; |
| /** |
| * The number of operations of the '<em>Import</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int IMPORT_OPERATION_COUNT = NamedElementImpl.NAMED_ELEMENT_OPERATION_COUNT + 0; |
| /** |
| * The cached value of the '{@link #getImportedNamespace() <em>Imported Namespace</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getImportedNamespace() |
| * @generated |
| * @ordered |
| */ |
| protected Namespace importedNamespace; |
| /** |
| * The default value of the '{@link #getXmiidVersion() <em>Xmiid Version</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * @since 1.4 |
| * <!-- end-user-doc --> |
| * @see #getXmiidVersion() |
| * @generated |
| * @ordered |
| */ |
| protected static final Number XMIID_VERSION_EDEFAULT = (Number)PivotFactory.eINSTANCE.createFromString(PivotPackage.eINSTANCE.getInteger(), "0"); //$NON-NLS-1$ |
| /** |
| * The cached value of the '{@link #getXmiidVersion() <em>Xmiid Version</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * @since 1.4 |
| * <!-- end-user-doc --> |
| * @see #getXmiidVersion() |
| * @generated |
| * @ordered |
| */ |
| protected Number xmiidVersion = XMIID_VERSION_EDEFAULT; |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ImportImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return PivotPackage.Literals.IMPORT; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Namespace getImportedNamespace() |
| { |
| if (importedNamespace != null && importedNamespace.eIsProxy()) |
| { |
| InternalEObject oldImportedNamespace = (InternalEObject)importedNamespace; |
| importedNamespace = (Namespace)eResolveProxy(oldImportedNamespace); |
| if (importedNamespace != oldImportedNamespace) |
| { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, 5, oldImportedNamespace, importedNamespace)); |
| } |
| } |
| return importedNamespace; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Namespace basicGetImportedNamespace() |
| { |
| return importedNamespace; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setImportedNamespace(Namespace newImportedNamespace) |
| { |
| Namespace oldImportedNamespace = importedNamespace; |
| importedNamespace = newImportedNamespace; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 5, oldImportedNamespace, importedNamespace)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * @since 1.4 |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Number getXmiidVersion() |
| { |
| return xmiidVersion; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * @since 1.4 |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setXmiidVersion(Number newXmiidVersion) |
| { |
| Number oldXmiidVersion = xmiidVersion; |
| xmiidVersion = newXmiidVersion; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 6, oldXmiidVersion, xmiidVersion)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case 0: |
| return getAnnotatingComments(); |
| case 1: |
| return getOwnedAnnotations(); |
| case 2: |
| return getOwnedComments(); |
| case 3: |
| return getOwnedExtensions(); |
| case 4: |
| return getName(); |
| case 5: |
| if (resolve) return getImportedNamespace(); |
| return basicGetImportedNamespace(); |
| case 6: |
| return getXmiidVersion(); |
| } |
| return eDynamicGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case 0: |
| getAnnotatingComments().clear(); |
| getAnnotatingComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case 1: |
| getOwnedAnnotations().clear(); |
| getOwnedAnnotations().addAll((Collection<? extends Element>)newValue); |
| return; |
| case 2: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case 3: |
| getOwnedExtensions().clear(); |
| getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue); |
| return; |
| case 4: |
| setName((String)newValue); |
| return; |
| case 5: |
| setImportedNamespace((Namespace)newValue); |
| return; |
| case 6: |
| setXmiidVersion((Number)newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case 0: |
| getAnnotatingComments().clear(); |
| return; |
| case 1: |
| getOwnedAnnotations().clear(); |
| return; |
| case 2: |
| getOwnedComments().clear(); |
| return; |
| case 3: |
| getOwnedExtensions().clear(); |
| return; |
| case 4: |
| setName(NAME_EDEFAULT); |
| return; |
| case 5: |
| setImportedNamespace((Namespace)null); |
| return; |
| case 6: |
| setXmiidVersion(XMIID_VERSION_EDEFAULT); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case 0: |
| return annotatingComments != null && !annotatingComments.isEmpty(); |
| case 1: |
| return ownedAnnotations != null && !ownedAnnotations.isEmpty(); |
| case 2: |
| return ownedComments != null && !ownedComments.isEmpty(); |
| case 3: |
| return ownedExtensions != null && !ownedExtensions.isEmpty(); |
| case 4: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case 5: |
| return importedNamespace != null; |
| case 6: |
| return XMIID_VERSION_EDEFAULT == null ? xmiidVersion != null : !XMIID_VERSION_EDEFAULT.equals(xmiidVersion); |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public String toString() { |
| return super.toString(); |
| } |
| |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitImport(this); |
| } |
| |
| } //ImportImpl |