| /** |
| * ******************************************************************************* |
| * Copyright (c) 2015-2021 Robert Bosch GmbH and others. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Generated using Eclipse EMF |
| * |
| * ******************************************************************************* |
| */ |
| package org.eclipse.app4mc.amalthea.model.impl; |
| |
| import java.lang.reflect.InvocationTargetException; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.app4mc.amalthea.model.AmaltheaPackage; |
| import org.eclipse.app4mc.amalthea.model.Component; |
| import org.eclipse.app4mc.amalthea.model.ComponentInterface; |
| import org.eclipse.app4mc.amalthea.model.ComponentPort; |
| import org.eclipse.app4mc.amalthea.model.INamed; |
| import org.eclipse.app4mc.amalthea.model.IReferable; |
| import org.eclipse.app4mc.amalthea.model.ITaggable; |
| import org.eclipse.app4mc.amalthea.model.InterfaceKind; |
| import org.eclipse.app4mc.amalthea.model.ReferableBaseObject; |
| import org.eclipse.app4mc.amalthea.model.Tag; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.common.util.BasicEList; |
| 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.EObjectResolvingEList; |
| import org.eclipse.emf.ecore.xcore.lib.XcoreCollectionLiterals; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Component Port</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.ComponentPortImpl#getTags <em>Tags</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.ComponentPortImpl#getContainingComponent <em>Containing Component</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.ComponentPortImpl#getKind <em>Kind</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.ComponentPortImpl#getInterface <em>Interface</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ComponentPortImpl extends ReferableBaseObjectImpl implements ComponentPort { |
| /** |
| * The cached value of the '{@link #getTags() <em>Tags</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTags() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Tag> tags; |
| |
| /** |
| * The default value of the '{@link #getKind() <em>Kind</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKind() |
| * @generated |
| * @ordered |
| */ |
| protected static final InterfaceKind KIND_EDEFAULT = InterfaceKind._UNDEFINED_; |
| |
| /** |
| * The cached value of the '{@link #getKind() <em>Kind</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKind() |
| * @generated |
| * @ordered |
| */ |
| protected InterfaceKind kind = KIND_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getInterface() <em>Interface</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getInterface() |
| * @generated |
| * @ordered |
| */ |
| protected ComponentInterface interface_; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ComponentPortImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getComponentPort(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<Tag> getTags() { |
| if (tags == null) { |
| tags = new EObjectResolvingEList<Tag>(Tag.class, this, AmaltheaPackage.COMPONENT_PORT__TAGS); |
| } |
| return tags; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Component getContainingComponent() { |
| if (eContainerFeatureID() != AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT) return null; |
| return (Component)eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Component basicGetContainingComponent() { |
| if (eContainerFeatureID() != AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT) return null; |
| return (Component)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public InterfaceKind getKind() { |
| return kind; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setKind(InterfaceKind newKind) { |
| InterfaceKind oldKind = kind; |
| kind = newKind == null ? KIND_EDEFAULT : newKind; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.COMPONENT_PORT__KIND, oldKind, kind)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public ComponentInterface getInterface() { |
| if (interface_ != null && interface_.eIsProxy()) { |
| InternalEObject oldInterface = (InternalEObject)interface_; |
| interface_ = (ComponentInterface)eResolveProxy(oldInterface); |
| if (interface_ != oldInterface) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AmaltheaPackage.COMPONENT_PORT__INTERFACE, oldInterface, interface_)); |
| } |
| } |
| return interface_; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ComponentInterface basicGetInterface() { |
| return interface_; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setInterface(ComponentInterface newInterface) { |
| ComponentInterface oldInterface = interface_; |
| interface_ = newInterface; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.COMPONENT_PORT__INTERFACE, oldInterface, interface_)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<String> getNamePrefixSegments() { |
| EList<String> _elvis = null; |
| Component _containingComponent = this.getContainingComponent(); |
| EList<String> _qualifiedNameSegments = null; |
| if (_containingComponent!=null) { |
| _qualifiedNameSegments=_containingComponent.getQualifiedNameSegments(); |
| } |
| if (_qualifiedNameSegments != null) { |
| _elvis = _qualifiedNameSegments; |
| } else { |
| BasicEList<String> _newBasicEList = XcoreCollectionLiterals.<String>newBasicEList(); |
| _elvis = _newBasicEList; |
| } |
| return _elvis; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return eBasicSetContainer(otherEnd, AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT, 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 AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT: |
| return eBasicSetContainer(null, AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| switch (eContainerFeatureID()) { |
| case AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT: |
| return eInternalContainer().eInverseRemove(this, AmaltheaPackage.COMPONENT__PORTS, Component.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 AmaltheaPackage.COMPONENT_PORT__TAGS: |
| return getTags(); |
| case AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT: |
| if (resolve) return getContainingComponent(); |
| return basicGetContainingComponent(); |
| case AmaltheaPackage.COMPONENT_PORT__KIND: |
| return getKind(); |
| case AmaltheaPackage.COMPONENT_PORT__INTERFACE: |
| if (resolve) return getInterface(); |
| return basicGetInterface(); |
| } |
| 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 AmaltheaPackage.COMPONENT_PORT__TAGS: |
| getTags().clear(); |
| getTags().addAll((Collection<? extends Tag>)newValue); |
| return; |
| case AmaltheaPackage.COMPONENT_PORT__KIND: |
| setKind((InterfaceKind)newValue); |
| return; |
| case AmaltheaPackage.COMPONENT_PORT__INTERFACE: |
| setInterface((ComponentInterface)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.COMPONENT_PORT__TAGS: |
| getTags().clear(); |
| return; |
| case AmaltheaPackage.COMPONENT_PORT__KIND: |
| setKind(KIND_EDEFAULT); |
| return; |
| case AmaltheaPackage.COMPONENT_PORT__INTERFACE: |
| setInterface((ComponentInterface)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.COMPONENT_PORT__TAGS: |
| return tags != null && !tags.isEmpty(); |
| case AmaltheaPackage.COMPONENT_PORT__CONTAINING_COMPONENT: |
| return basicGetContainingComponent() != null; |
| case AmaltheaPackage.COMPONENT_PORT__KIND: |
| return kind != KIND_EDEFAULT; |
| case AmaltheaPackage.COMPONENT_PORT__INTERFACE: |
| return interface_ != null; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == ITaggable.class) { |
| switch (derivedFeatureID) { |
| case AmaltheaPackage.COMPONENT_PORT__TAGS: return AmaltheaPackage.ITAGGABLE__TAGS; |
| 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 == ITaggable.class) { |
| switch (baseFeatureID) { |
| case AmaltheaPackage.ITAGGABLE__TAGS: return AmaltheaPackage.COMPONENT_PORT__TAGS; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedOperationID(int baseOperationID, Class<?> baseClass) { |
| if (baseClass == INamed.class) { |
| switch (baseOperationID) { |
| case AmaltheaPackage.INAMED___GET_NAME_PREFIX_SEGMENTS: return AmaltheaPackage.COMPONENT_PORT___GET_NAME_PREFIX_SEGMENTS; |
| default: return super.eDerivedOperationID(baseOperationID, baseClass); |
| } |
| } |
| if (baseClass == IReferable.class) { |
| switch (baseOperationID) { |
| case AmaltheaPackage.IREFERABLE___GET_NAME_PREFIX_SEGMENTS: return AmaltheaPackage.COMPONENT_PORT___GET_NAME_PREFIX_SEGMENTS; |
| default: return super.eDerivedOperationID(baseOperationID, baseClass); |
| } |
| } |
| if (baseClass == ReferableBaseObject.class) { |
| switch (baseOperationID) { |
| case AmaltheaPackage.REFERABLE_BASE_OBJECT___GET_NAME_PREFIX_SEGMENTS: return AmaltheaPackage.COMPONENT_PORT___GET_NAME_PREFIX_SEGMENTS; |
| default: return super.eDerivedOperationID(baseOperationID, baseClass); |
| } |
| } |
| if (baseClass == ITaggable.class) { |
| switch (baseOperationID) { |
| default: return -1; |
| } |
| } |
| return super.eDerivedOperationID(baseOperationID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { |
| switch (operationID) { |
| case AmaltheaPackage.COMPONENT_PORT___GET_NAME_PREFIX_SEGMENTS: |
| return getNamePrefixSegments(); |
| } |
| return super.eInvoke(operationID, arguments); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (kind: "); |
| result.append(kind); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ComponentPortImpl |