| /** |
| * Copyright (c) 2022 CEA LIST and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * CEA LIST - Initial API and implementation |
| */ |
| package org.eclipse.papyrus.aas.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.impl.MinimalEObjectImpl; |
| |
| import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| import org.eclipse.papyrus.aas.AASPackage; |
| import org.eclipse.papyrus.aas.LangString; |
| import org.eclipse.papyrus.aas.Referable; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Referable</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.papyrus.aas.impl.ReferableImpl#getIdShort <em>Id Short</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.ReferableImpl#getCategory <em>Category</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.ReferableImpl#getDescription <em>Description</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.ReferableImpl#getBase_Class <em>Base Class</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public abstract class ReferableImpl extends MinimalEObjectImpl.Container implements Referable { |
| /** |
| * The default value of the '{@link #getIdShort() <em>Id Short</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getIdShort() |
| * @generated |
| * @ordered |
| */ |
| protected static final String ID_SHORT_EDEFAULT = null; |
| |
| /** |
| * The default value of the '{@link #getCategory() <em>Category</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getCategory() |
| * @generated |
| * @ordered |
| */ |
| protected static final String CATEGORY_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getCategory() <em>Category</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getCategory() |
| * @generated |
| * @ordered |
| */ |
| protected String category = CATEGORY_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getDescription() <em>Description</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getDescription() |
| * @generated |
| * @ordered |
| */ |
| protected EList<LangString> description; |
| |
| /** |
| * The cached value of the '{@link #getBase_Class() <em>Base Class</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getBase_Class() |
| * @generated |
| * @ordered |
| */ |
| protected org.eclipse.uml2.uml.Class base_Class; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ReferableImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AASPackage.Literals.REFERABLE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getIdShort() { |
| // get the name of the Referable Element |
| if (getBase_Class() != null) { |
| String name = getBase_Class().getName(); |
| // remove space |
| if (name != null) { |
| String idShort = name.replace(" ", ""); |
| return idShort; |
| } |
| } |
| return null; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getCategory() { |
| return category; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setCategory(String newCategory) { |
| String oldCategory = category; |
| category = newCategory; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.REFERABLE__CATEGORY, oldCategory, category)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<LangString> getDescription() { |
| if (description == null) { |
| description = new EObjectContainmentEList<LangString>(LangString.class, this, AASPackage.REFERABLE__DESCRIPTION); |
| } |
| return description; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public org.eclipse.uml2.uml.Class getBase_Class() { |
| if (base_Class != null && base_Class.eIsProxy()) { |
| InternalEObject oldBase_Class = (InternalEObject)base_Class; |
| base_Class = (org.eclipse.uml2.uml.Class)eResolveProxy(oldBase_Class); |
| if (base_Class != oldBase_Class) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AASPackage.REFERABLE__BASE_CLASS, oldBase_Class, base_Class)); |
| } |
| } |
| return base_Class; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public org.eclipse.uml2.uml.Class basicGetBase_Class() { |
| return base_Class; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setBase_Class(org.eclipse.uml2.uml.Class newBase_Class) { |
| org.eclipse.uml2.uml.Class oldBase_Class = base_Class; |
| base_Class = newBase_Class; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.REFERABLE__BASE_CLASS, oldBase_Class, base_Class)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case AASPackage.REFERABLE__DESCRIPTION: |
| return ((InternalEList<?>)getDescription()).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 AASPackage.REFERABLE__ID_SHORT: |
| return getIdShort(); |
| case AASPackage.REFERABLE__CATEGORY: |
| return getCategory(); |
| case AASPackage.REFERABLE__DESCRIPTION: |
| return getDescription(); |
| case AASPackage.REFERABLE__BASE_CLASS: |
| if (resolve) return getBase_Class(); |
| return basicGetBase_Class(); |
| } |
| 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 AASPackage.REFERABLE__CATEGORY: |
| setCategory((String)newValue); |
| return; |
| case AASPackage.REFERABLE__DESCRIPTION: |
| getDescription().clear(); |
| getDescription().addAll((Collection<? extends LangString>)newValue); |
| return; |
| case AASPackage.REFERABLE__BASE_CLASS: |
| setBase_Class((org.eclipse.uml2.uml.Class)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AASPackage.REFERABLE__CATEGORY: |
| setCategory(CATEGORY_EDEFAULT); |
| return; |
| case AASPackage.REFERABLE__DESCRIPTION: |
| getDescription().clear(); |
| return; |
| case AASPackage.REFERABLE__BASE_CLASS: |
| setBase_Class((org.eclipse.uml2.uml.Class)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AASPackage.REFERABLE__ID_SHORT: |
| return ID_SHORT_EDEFAULT == null ? getIdShort() != null : !ID_SHORT_EDEFAULT.equals(getIdShort()); |
| case AASPackage.REFERABLE__CATEGORY: |
| return CATEGORY_EDEFAULT == null ? category != null : !CATEGORY_EDEFAULT.equals(category); |
| case AASPackage.REFERABLE__DESCRIPTION: |
| return description != null && !description.isEmpty(); |
| case AASPackage.REFERABLE__BASE_CLASS: |
| return base_Class != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (category: "); |
| result.append(category); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ReferableImpl |