| /** |
| * ******************************************************************************* |
| * 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.AmaltheaIndex; |
| import org.eclipse.app4mc.amalthea.model.AmaltheaPackage; |
| import org.eclipse.app4mc.amalthea.model.HwConnection; |
| import org.eclipse.app4mc.amalthea.model.HwPort; |
| import org.eclipse.app4mc.amalthea.model.HwStructure; |
| 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.PortInterface; |
| import org.eclipse.app4mc.amalthea.model.PortType; |
| 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.util.BasicEList; |
| import org.eclipse.emf.common.util.EList; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.emf.ecore.EReference; |
| 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>Hw Port</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.HwPortImpl#getTags <em>Tags</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.HwPortImpl#getBitWidth <em>Bit Width</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.HwPortImpl#getPriority <em>Priority</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.HwPortImpl#getPortType <em>Port Type</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.HwPortImpl#getPortInterface <em>Port Interface</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.HwPortImpl#isDelegated <em>Delegated</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.HwPortImpl#getConnections <em>Connections</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class HwPortImpl extends ReferableBaseObjectImpl implements HwPort { |
| /** |
| * 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 #getBitWidth() <em>Bit Width</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getBitWidth() |
| * @generated |
| * @ordered |
| */ |
| protected static final int BIT_WIDTH_EDEFAULT = 0; |
| |
| /** |
| * The cached value of the '{@link #getBitWidth() <em>Bit Width</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getBitWidth() |
| * @generated |
| * @ordered |
| */ |
| protected int bitWidth = BIT_WIDTH_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getPriority() <em>Priority</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPriority() |
| * @generated |
| * @ordered |
| */ |
| protected static final int PRIORITY_EDEFAULT = 0; |
| |
| /** |
| * The cached value of the '{@link #getPriority() <em>Priority</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPriority() |
| * @generated |
| * @ordered |
| */ |
| protected int priority = PRIORITY_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getPortType() <em>Port Type</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPortType() |
| * @generated |
| * @ordered |
| */ |
| protected static final PortType PORT_TYPE_EDEFAULT = PortType._UNDEFINED_; |
| |
| /** |
| * The cached value of the '{@link #getPortType() <em>Port Type</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPortType() |
| * @generated |
| * @ordered |
| */ |
| protected PortType portType = PORT_TYPE_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getPortInterface() <em>Port Interface</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPortInterface() |
| * @generated |
| * @ordered |
| */ |
| protected static final PortInterface PORT_INTERFACE_EDEFAULT = PortInterface._UNDEFINED_; |
| |
| /** |
| * The cached value of the '{@link #getPortInterface() <em>Port Interface</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPortInterface() |
| * @generated |
| * @ordered |
| */ |
| protected PortInterface portInterface = PORT_INTERFACE_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #isDelegated() <em>Delegated</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isDelegated() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean DELEGATED_EDEFAULT = false; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected HwPortImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getHwPort(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<Tag> getTags() { |
| if (tags == null) { |
| tags = new EObjectResolvingEList<Tag>(Tag.class, this, AmaltheaPackage.HW_PORT__TAGS); |
| } |
| return tags; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int getBitWidth() { |
| return bitWidth; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setBitWidth(int newBitWidth) { |
| int oldBitWidth = bitWidth; |
| bitWidth = newBitWidth; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.HW_PORT__BIT_WIDTH, oldBitWidth, bitWidth)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int getPriority() { |
| return priority; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setPriority(int newPriority) { |
| int oldPriority = priority; |
| priority = newPriority; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.HW_PORT__PRIORITY, oldPriority, priority)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public PortType getPortType() { |
| return portType; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setPortType(PortType newPortType) { |
| PortType oldPortType = portType; |
| portType = newPortType == null ? PORT_TYPE_EDEFAULT : newPortType; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.HW_PORT__PORT_TYPE, oldPortType, portType)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public PortInterface getPortInterface() { |
| return portInterface; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setPortInterface(PortInterface newPortInterface) { |
| PortInterface oldPortInterface = portInterface; |
| portInterface = newPortInterface == null ? PORT_INTERFACE_EDEFAULT : newPortInterface; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.HW_PORT__PORT_INTERFACE, oldPortInterface, portInterface)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean isDelegated() { |
| EObject _eContainer = this.eContainer(); |
| return (_eContainer instanceof HwStructure); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<HwConnection> getConnections() { |
| EReference _hwConnection_Port1 = AmaltheaPackage.eINSTANCE.getHwConnection_Port1(); |
| EReference _hwConnection_Port2 = AmaltheaPackage.eINSTANCE.getHwConnection_Port2(); |
| return AmaltheaIndex.<HwConnection>getInverseReferences(this, AmaltheaPackage.eINSTANCE.getHwPort_Connections(), |
| java.util.Collections.<EReference>unmodifiableSet(org.eclipse.xtext.xbase.lib.CollectionLiterals.<EReference>newHashSet(_hwConnection_Port1, _hwConnection_Port2))); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<String> getNamePrefixSegments() { |
| EList<String> _elvis = null; |
| INamed _namedContainer = this.getNamedContainer(); |
| EList<String> _qualifiedNameSegments = null; |
| if (_namedContainer!=null) { |
| _qualifiedNameSegments=_namedContainer.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 Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case AmaltheaPackage.HW_PORT__TAGS: |
| return getTags(); |
| case AmaltheaPackage.HW_PORT__BIT_WIDTH: |
| return getBitWidth(); |
| case AmaltheaPackage.HW_PORT__PRIORITY: |
| return getPriority(); |
| case AmaltheaPackage.HW_PORT__PORT_TYPE: |
| return getPortType(); |
| case AmaltheaPackage.HW_PORT__PORT_INTERFACE: |
| return getPortInterface(); |
| case AmaltheaPackage.HW_PORT__DELEGATED: |
| return isDelegated(); |
| case AmaltheaPackage.HW_PORT__CONNECTIONS: |
| return getConnections(); |
| } |
| 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.HW_PORT__TAGS: |
| getTags().clear(); |
| getTags().addAll((Collection<? extends Tag>)newValue); |
| return; |
| case AmaltheaPackage.HW_PORT__BIT_WIDTH: |
| setBitWidth((Integer)newValue); |
| return; |
| case AmaltheaPackage.HW_PORT__PRIORITY: |
| setPriority((Integer)newValue); |
| return; |
| case AmaltheaPackage.HW_PORT__PORT_TYPE: |
| setPortType((PortType)newValue); |
| return; |
| case AmaltheaPackage.HW_PORT__PORT_INTERFACE: |
| setPortInterface((PortInterface)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.HW_PORT__TAGS: |
| getTags().clear(); |
| return; |
| case AmaltheaPackage.HW_PORT__BIT_WIDTH: |
| setBitWidth(BIT_WIDTH_EDEFAULT); |
| return; |
| case AmaltheaPackage.HW_PORT__PRIORITY: |
| setPriority(PRIORITY_EDEFAULT); |
| return; |
| case AmaltheaPackage.HW_PORT__PORT_TYPE: |
| setPortType(PORT_TYPE_EDEFAULT); |
| return; |
| case AmaltheaPackage.HW_PORT__PORT_INTERFACE: |
| setPortInterface(PORT_INTERFACE_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.HW_PORT__TAGS: |
| return tags != null && !tags.isEmpty(); |
| case AmaltheaPackage.HW_PORT__BIT_WIDTH: |
| return bitWidth != BIT_WIDTH_EDEFAULT; |
| case AmaltheaPackage.HW_PORT__PRIORITY: |
| return priority != PRIORITY_EDEFAULT; |
| case AmaltheaPackage.HW_PORT__PORT_TYPE: |
| return portType != PORT_TYPE_EDEFAULT; |
| case AmaltheaPackage.HW_PORT__PORT_INTERFACE: |
| return portInterface != PORT_INTERFACE_EDEFAULT; |
| case AmaltheaPackage.HW_PORT__DELEGATED: |
| return isDelegated() != DELEGATED_EDEFAULT; |
| case AmaltheaPackage.HW_PORT__CONNECTIONS: |
| return !getConnections().isEmpty(); |
| } |
| 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.HW_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.HW_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.HW_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.HW_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.HW_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.HW_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(" (bitWidth: "); |
| result.append(bitWidth); |
| result.append(", priority: "); |
| result.append(priority); |
| result.append(", portType: "); |
| result.append(portType); |
| result.append(", portInterface: "); |
| result.append(portInterface); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //HwPortImpl |