/******************************************************************************* * Copyright (c) 2010, 2015 Willink Transformations 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: * E.D.Willink - initial API and implementation *******************************************************************************/ package org.eclipse.ocl.xtext.essentialoclcs.impl; import java.util.Collection; 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.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.ocl.xtext.basecs.util.BaseCSVisitor; import org.eclipse.ocl.xtext.essentialoclcs.CollectionLiteralExpCS; import org.eclipse.ocl.xtext.essentialoclcs.CollectionLiteralPartCS; import org.eclipse.ocl.xtext.essentialoclcs.CollectionTypeCS; import org.eclipse.ocl.xtext.essentialoclcs.EssentialOCLCSPackage; import org.eclipse.ocl.xtext.essentialoclcs.util.EssentialOCLCSVisitor; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Collection Literal Exp CS</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link org.eclipse.ocl.xtext.essentialoclcs.impl.CollectionLiteralExpCSImpl#getOwnedParts <em>Owned Parts</em>}</li> * <li>{@link org.eclipse.ocl.xtext.essentialoclcs.impl.CollectionLiteralExpCSImpl#getOwnedType <em>Owned Type</em>}</li> * </ul> * * @generated */ public class CollectionLiteralExpCSImpl extends LiteralExpCSImpl implements CollectionLiteralExpCS { /** * The cached value of the '{@link #getOwnedParts() <em>Owned Parts</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOwnedParts() * @generated * @ordered */ protected EList<CollectionLiteralPartCS> ownedParts; /** * The cached value of the '{@link #getOwnedType() <em>Owned Type</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getOwnedType() * @generated * @ordered */ protected CollectionTypeCS ownedType; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected CollectionLiteralExpCSImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return EssentialOCLCSPackage.Literals.COLLECTION_LITERAL_EXP_CS; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public CollectionTypeCS getOwnedType() { return ownedType; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetOwnedType(CollectionTypeCS newOwnedType, NotificationChain msgs) { CollectionTypeCS oldOwnedType = ownedType; ownedType = newOwnedType; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE, oldOwnedType, newOwnedType); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setOwnedType(CollectionTypeCS newOwnedType) { if (newOwnedType != ownedType) { NotificationChain msgs = null; if (ownedType != null) msgs = ((InternalEObject)ownedType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE, null, msgs); if (newOwnedType != null) msgs = ((InternalEObject)newOwnedType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE, null, msgs); msgs = basicSetOwnedType(newOwnedType, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE, newOwnedType, newOwnedType)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public EList<CollectionLiteralPartCS> getOwnedParts() { if (ownedParts == null) { ownedParts = new EObjectContainmentEList<CollectionLiteralPartCS>(CollectionLiteralPartCS.class, this, EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_PARTS); } return ownedParts; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_PARTS: return ((InternalEList<?>)getOwnedParts()).basicRemove(otherEnd, msgs); case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE: return basicSetOwnedType(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 EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_PARTS: return getOwnedParts(); case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE: return getOwnedType(); } 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 EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_PARTS: getOwnedParts().clear(); getOwnedParts().addAll((Collection<? extends CollectionLiteralPartCS>)newValue); return; case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE: setOwnedType((CollectionTypeCS)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_PARTS: getOwnedParts().clear(); return; case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE: setOwnedType((CollectionTypeCS)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_PARTS: return ownedParts != null && !ownedParts.isEmpty(); case EssentialOCLCSPackage.COLLECTION_LITERAL_EXP_CS__OWNED_TYPE: return ownedType != null; } return super.eIsSet(featureID); } /** * {@inheritDoc} * @generated */ @SuppressWarnings("unchecked") @Override public <R> R accept(@NonNull BaseCSVisitor<R> visitor) { return (R) ((EssentialOCLCSVisitor<?>)visitor).visitCollectionLiteralExpCS(this); } } //CollectionLiteralExpCSImpl