| /******************************************************************************* |
| * Copyright (c) 2007, 2018 IBM Corporation, Zeligsoft Inc., 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: |
| * IBM - Initial API and implementation |
| * Zeligsoft - Bugs 248869, 207365 |
| *******************************************************************************/ |
| package org.eclipse.ocl.ecore.impl; |
| |
| 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.ecore.EClass; |
| import org.eclipse.emf.ecore.EClassifier; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.ocl.ecore.CollectionItem; |
| import org.eclipse.ocl.ecore.EcorePackage; |
| import org.eclipse.ocl.expressions.ExpressionsPackage; |
| import org.eclipse.ocl.expressions.OCLExpression; |
| import org.eclipse.ocl.expressions.operations.CollectionItemOperations; |
| import org.eclipse.ocl.utilities.Visitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Collection Item</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.ecore.impl.CollectionItemImpl#getItem <em>Item</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class CollectionItemImpl |
| extends CollectionLiteralPartImpl |
| implements CollectionItem { |
| |
| /** |
| * The cached value of the '{@link #getItem() <em>Item</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getItem() |
| * @generated |
| * @ordered |
| */ |
| protected OCLExpression<EClassifier> item; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected CollectionItemImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return EcorePackage.Literals.COLLECTION_ITEM; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public OCLExpression<EClassifier> getItem() { |
| return item; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetItem(OCLExpression<EClassifier> newItem, |
| NotificationChain msgs) { |
| OCLExpression<EClassifier> oldItem = item; |
| item = newItem; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, |
| Notification.SET, EcorePackage.COLLECTION_ITEM__ITEM, oldItem, |
| newItem); |
| if (msgs == null) |
| msgs = notification; |
| else |
| msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setItem(OCLExpression<EClassifier> newItem) { |
| if (newItem != item) { |
| NotificationChain msgs = null; |
| if (item != null) |
| msgs = ((InternalEObject) item).eInverseRemove(this, |
| EOPPOSITE_FEATURE_BASE - EcorePackage.COLLECTION_ITEM__ITEM, |
| null, msgs); |
| if (newItem != null) |
| msgs = ((InternalEObject) newItem).eInverseAdd(this, |
| EOPPOSITE_FEATURE_BASE - EcorePackage.COLLECTION_ITEM__ITEM, |
| null, msgs); |
| msgs = basicSetItem(newItem, msgs); |
| if (msgs != null) |
| msgs.dispatch(); |
| } else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, |
| EcorePackage.COLLECTION_ITEM__ITEM, newItem, newItem)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public boolean checkItemType(DiagnosticChain diagnostics, |
| Map<Object, Object> context) { |
| return CollectionItemOperations.checkItemType(this, diagnostics, |
| context); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, |
| int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case EcorePackage.COLLECTION_ITEM__ITEM : |
| return basicSetItem(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case EcorePackage.COLLECTION_ITEM__ITEM : |
| return getItem(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case EcorePackage.COLLECTION_ITEM__ITEM : |
| setItem((OCLExpression<EClassifier>) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case EcorePackage.COLLECTION_ITEM__ITEM : |
| setItem((OCLExpression<EClassifier>) null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case EcorePackage.COLLECTION_ITEM__ITEM : |
| return item != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, |
| Class<?> baseClass) { |
| if (baseClass == org.eclipse.ocl.expressions.CollectionItem.class) { |
| switch (derivedFeatureID) { |
| case EcorePackage.COLLECTION_ITEM__ITEM : |
| return ExpressionsPackage.COLLECTION_ITEM__ITEM; |
| default : |
| return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, |
| Class<?> baseClass) { |
| if (baseClass == org.eclipse.ocl.expressions.CollectionItem.class) { |
| switch (baseFeatureID) { |
| case ExpressionsPackage.COLLECTION_ITEM__ITEM : |
| return EcorePackage.COLLECTION_ITEM__ITEM; |
| default : |
| return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * @generated NOT |
| */ |
| @Override |
| @SuppressWarnings("unchecked") |
| public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) { |
| return ((Visitor<T, EClassifier, ?, ?, ?, ?, ?, ?, ?, ?>) v) |
| .visitCollectionItem(this); |
| } |
| |
| } //CollectionItemImpl |