| /******************************************************************************* |
| * Copyright (c) 2010, 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.xtext.basecs.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.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.ocl.xtext.basecs.BaseCSPackage; |
| import org.eclipse.ocl.xtext.basecs.ClassCS; |
| import org.eclipse.ocl.xtext.basecs.ConstraintCS; |
| import org.eclipse.ocl.xtext.basecs.PackageCS; |
| import org.eclipse.ocl.xtext.basecs.TemplateSignatureCS; |
| import org.eclipse.ocl.xtext.basecs.TemplateableElementCS; |
| import org.eclipse.ocl.xtext.basecs.TypeCS; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Classifier CS</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.ClassCSImpl#getOwnedSignature <em>Owned Signature</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.ClassCSImpl#getInstanceClassName <em>Instance Class Name</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.ClassCSImpl#getOwnedConstraints <em>Owned Constraints</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.ClassCSImpl#getOwningPackage <em>Owning Package</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public abstract class ClassCSImpl extends NamedElementCSImpl implements ClassCS { |
| /** |
| * The number of structural features of the '<em>Class CS</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int CLASS_CS_FEATURE_COUNT = NamedElementCSImpl.NAMED_ELEMENT_CS_FEATURE_COUNT + 4; |
| /** |
| * The cached value of the '{@link #getOwnedSignature() <em>Owned Signature</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedSignature() |
| * @generated |
| * @ordered |
| */ |
| protected TemplateSignatureCS ownedSignature; |
| /** |
| * The default value of the '{@link #getInstanceClassName() <em>Instance Class Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getInstanceClassName() |
| * @generated |
| * @ordered |
| */ |
| protected static final String INSTANCE_CLASS_NAME_EDEFAULT = null; |
| /** |
| * The cached value of the '{@link #getInstanceClassName() <em>Instance Class Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getInstanceClassName() |
| * @generated |
| * @ordered |
| */ |
| protected String instanceClassName = INSTANCE_CLASS_NAME_EDEFAULT; |
| /** |
| * The cached value of the '{@link #getOwnedConstraints() <em>Owned Constraints</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedConstraints() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ConstraintCS> ownedConstraints; |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ClassCSImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return BaseCSPackage.Literals.CLASS_CS; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public TemplateSignatureCS getOwnedSignature() { |
| return ownedSignature; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedSignature(TemplateSignatureCS newOwnedSignature, NotificationChain msgs) |
| { |
| TemplateSignatureCS oldOwnedSignature = ownedSignature; |
| ownedSignature = newOwnedSignature; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, 6, oldOwnedSignature, newOwnedSignature); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedSignature(TemplateSignatureCS newOwnedSignature) { |
| if (newOwnedSignature != ownedSignature) |
| { |
| NotificationChain msgs = null; |
| if (ownedSignature != null) |
| msgs = ((InternalEObject)ownedSignature).eInverseRemove(this, 6, TemplateSignatureCS.class, msgs); |
| if (newOwnedSignature != null) |
| msgs = ((InternalEObject)newOwnedSignature).eInverseAdd(this, 6, TemplateSignatureCS.class, msgs); |
| msgs = basicSetOwnedSignature(newOwnedSignature, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 6, newOwnedSignature, newOwnedSignature)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public PackageCS getOwningPackage() { |
| if (eContainerFeatureID() != (9)) return null; |
| return (PackageCS)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwningPackage(PackageCS newOwningPackage, NotificationChain msgs) |
| { |
| msgs = eBasicSetContainer((InternalEObject)newOwningPackage, 9, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwningPackage(PackageCS newOwningPackage) |
| { |
| if (newOwningPackage != eInternalContainer() || (eContainerFeatureID() != (9) && newOwningPackage != null)) |
| { |
| if (EcoreUtil.isAncestor(this, newOwningPackage)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); //$NON-NLS-1$ |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newOwningPackage != null) |
| msgs = ((InternalEObject)newOwningPackage).eInverseAdd(this, 9, PackageCS.class, msgs); |
| msgs = basicSetOwningPackage(newOwningPackage, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 9, newOwningPackage, newOwningPackage)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getInstanceClassName() |
| { |
| return instanceClassName; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setInstanceClassName(String newInstanceClassName) |
| { |
| String oldInstanceClassName = instanceClassName; |
| instanceClassName = newInstanceClassName; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 7, oldInstanceClassName, instanceClassName)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<ConstraintCS> getOwnedConstraints() |
| { |
| if (ownedConstraints == null) |
| { |
| ownedConstraints = new EObjectContainmentEList<ConstraintCS>(ConstraintCS.class, this, 8); |
| } |
| return ownedConstraints; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public String toString() { |
| return super.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public TemplateSignatureCS getTemplateSignature() { |
| return getOwnedSignature(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) |
| { |
| case 6: |
| if (ownedSignature != null) |
| msgs = ((InternalEObject)ownedSignature).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - (6), null, msgs); |
| return basicSetOwnedSignature((TemplateSignatureCS)otherEnd, msgs); |
| case 9: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetOwningPackage((PackageCS)otherEnd, msgs); |
| } |
| return super.eInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) |
| { |
| case 6: |
| return basicSetOwnedSignature(null, msgs); |
| case 8: |
| return ((InternalEList<?>)getOwnedConstraints()).basicRemove(otherEnd, msgs); |
| case 9: |
| return basicSetOwningPackage(null, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) |
| { |
| case 9: |
| return eInternalContainer().eInverseRemove(this, 9, PackageCS.class, msgs); |
| } |
| return super.eBasicRemoveFromContainerFeature(msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) |
| { |
| case 6: |
| return getOwnedSignature(); |
| case 7: |
| return getInstanceClassName(); |
| case 8: |
| return getOwnedConstraints(); |
| case 9: |
| return getOwningPackage(); |
| } |
| 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 6: |
| setOwnedSignature((TemplateSignatureCS)newValue); |
| return; |
| case 7: |
| setInstanceClassName((String)newValue); |
| return; |
| case 8: |
| getOwnedConstraints().clear(); |
| getOwnedConstraints().addAll((Collection<? extends ConstraintCS>)newValue); |
| return; |
| case 9: |
| setOwningPackage((PackageCS)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) |
| { |
| case 6: |
| setOwnedSignature((TemplateSignatureCS)null); |
| return; |
| case 7: |
| setInstanceClassName(INSTANCE_CLASS_NAME_EDEFAULT); |
| return; |
| case 8: |
| getOwnedConstraints().clear(); |
| return; |
| case 9: |
| setOwningPackage((PackageCS)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) |
| { |
| case 6: |
| return ownedSignature != null; |
| case 7: |
| return INSTANCE_CLASS_NAME_EDEFAULT == null ? instanceClassName != null : !INSTANCE_CLASS_NAME_EDEFAULT.equals(instanceClassName); |
| case 8: |
| return ownedConstraints != null && !ownedConstraints.isEmpty(); |
| case 9: |
| return getOwningPackage() != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == TypeCS.class) |
| { |
| switch (derivedFeatureID) |
| { |
| default: return -1; |
| } |
| } |
| if (baseClass == TemplateableElementCS.class) |
| { |
| switch (derivedFeatureID) |
| { |
| case 6: return 2; |
| 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 == TypeCS.class) |
| { |
| switch (baseFeatureID) |
| { |
| default: return -1; |
| } |
| } |
| if (baseClass == TemplateableElementCS.class) |
| { |
| switch (baseFeatureID) |
| { |
| case 2: return 6; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| } //ClassifierCSImpl |