| /******************************************************************************* |
| * 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.EObjectContainmentWithInverseEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.ocl.xtext.basecs.BaseCSPackage; |
| import org.eclipse.ocl.xtext.basecs.ClassCS; |
| import org.eclipse.ocl.xtext.basecs.NamedElementCS; |
| import org.eclipse.ocl.xtext.basecs.NamespaceCS; |
| import org.eclipse.ocl.xtext.basecs.PackageCS; |
| import org.eclipse.ocl.xtext.basecs.util.BaseCSVisitor; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Package CS</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.PackageCSImpl#getName <em>Name</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.PackageCSImpl#getNsPrefix <em>Ns Prefix</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.PackageCSImpl#getNsURI <em>Ns URI</em>}</li> |
| * <li>{@link org.eclipse.ocl.xtext.basecs.impl.PackageCSImpl#getOwnedClasses <em>Owned Classes</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class PackageCSImpl extends PackageOwnerCSImpl implements PackageCS { |
| /** |
| * The number of structural features of the '<em>Package CS</em>' class. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| * @ordered |
| */ |
| public static final int PACKAGE_CS_FEATURE_COUNT = PackageOwnerCSImpl.PACKAGE_OWNER_CS_FEATURE_COUNT + 4; |
| /** |
| * The default value of the '{@link #getName() <em>Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getName() |
| * @generated |
| * @ordered |
| */ |
| protected static final String NAME_EDEFAULT = null; |
| /** |
| * The cached value of the '{@link #getName() <em>Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getName() |
| * @generated |
| * @ordered |
| */ |
| protected String name = NAME_EDEFAULT; |
| /** |
| * The default value of the '{@link #getNsPrefix() <em>Ns Prefix</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getNsPrefix() |
| * @generated |
| * @ordered |
| */ |
| protected static final String NS_PREFIX_EDEFAULT = null; |
| /** |
| * The cached value of the '{@link #getNsPrefix() <em>Ns Prefix</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getNsPrefix() |
| * @generated |
| * @ordered |
| */ |
| protected String nsPrefix = NS_PREFIX_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getNsURI() <em>Ns URI</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getNsURI() |
| * @generated |
| * @ordered |
| */ |
| protected static final String NS_URI_EDEFAULT = null; |
| /** |
| * The cached value of the '{@link #getNsURI() <em>Ns URI</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getNsURI() |
| * @generated |
| * @ordered |
| */ |
| protected String nsURI = NS_URI_EDEFAULT; |
| /** |
| * The cached value of the '{@link #getOwnedClasses() <em>Owned Classes</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedClasses() |
| * @generated |
| * @ordered |
| */ |
| protected EList<ClassCS> ownedClasses; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected PackageCSImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return BaseCSPackage.Literals.PACKAGE_CS; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getName() |
| { |
| return name; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setName(String newName) |
| { |
| String oldName = name; |
| name = newName; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 6, oldName, name)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<ClassCS> getOwnedClasses() |
| { |
| if (ownedClasses == null) |
| { |
| ownedClasses = new EObjectContainmentWithInverseEList<ClassCS>(ClassCS.class, this, 9, 9); |
| } |
| return ownedClasses; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getNsPrefix() |
| { |
| return nsPrefix; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setNsPrefix(String newNsPrefix) |
| { |
| String oldNsPrefix = nsPrefix; |
| nsPrefix = newNsPrefix; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 7, oldNsPrefix, nsPrefix)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getNsURI() |
| { |
| return nsURI; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setNsURI(String newNsURI) |
| { |
| String oldNsURI = nsURI; |
| nsURI = newNsURI; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, 8, oldNsURI, nsURI)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public String toString() { |
| return super.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case 9: |
| return ((InternalEList<InternalEObject>)(InternalEList<?>)getOwnedClasses()).basicAdd(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 9: |
| return ((InternalEList<?>)getOwnedClasses()).basicRemove(otherEnd, 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 6: |
| return getName(); |
| case 7: |
| return getNsPrefix(); |
| case 8: |
| return getNsURI(); |
| case 9: |
| return getOwnedClasses(); |
| } |
| 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: |
| setName((String)newValue); |
| return; |
| case 7: |
| setNsPrefix((String)newValue); |
| return; |
| case 8: |
| setNsURI((String)newValue); |
| return; |
| case 9: |
| getOwnedClasses().clear(); |
| getOwnedClasses().addAll((Collection<? extends ClassCS>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case 6: |
| setName(NAME_EDEFAULT); |
| return; |
| case 7: |
| setNsPrefix(NS_PREFIX_EDEFAULT); |
| return; |
| case 8: |
| setNsURI(NS_URI_EDEFAULT); |
| return; |
| case 9: |
| getOwnedClasses().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case 6: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case 7: |
| return NS_PREFIX_EDEFAULT == null ? nsPrefix != null : !NS_PREFIX_EDEFAULT.equals(nsPrefix); |
| case 8: |
| return NS_URI_EDEFAULT == null ? nsURI != null : !NS_URI_EDEFAULT.equals(nsURI); |
| case 9: |
| return ownedClasses != null && !ownedClasses.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) |
| { |
| if (baseClass == NamedElementCS.class) |
| { |
| switch (derivedFeatureID) |
| { |
| case 6: return 5; |
| default: return -1; |
| } |
| } |
| if (baseClass == NamespaceCS.class) |
| { |
| switch (derivedFeatureID) |
| { |
| 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 == NamedElementCS.class) |
| { |
| switch (baseFeatureID) |
| { |
| case 5: return 6; |
| default: return -1; |
| } |
| } |
| if (baseClass == NamespaceCS.class) |
| { |
| switch (baseFeatureID) |
| { |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * @generated |
| */ |
| @Override |
| public <R> R accept(@NonNull BaseCSVisitor<R> visitor) { |
| return visitor.visitPackageCS(this); |
| } |
| } //PackageCSImpl |