| /** |
| * ******************************************************************************* |
| * 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.ComponentInstance; |
| import org.eclipse.app4mc.amalthea.model.INamed; |
| import org.eclipse.app4mc.amalthea.model.IReferable; |
| import org.eclipse.app4mc.amalthea.model.ISystem; |
| import org.eclipse.app4mc.amalthea.model.ITaggable; |
| 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.util.EcoreUtil; |
| import org.eclipse.emf.ecore.xcore.lib.XcoreCollectionLiterals; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Component Instance</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.ComponentInstanceImpl#getTags <em>Tags</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.ComponentInstanceImpl#getContainingSystem <em>Containing System</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.ComponentInstanceImpl#getType <em>Type</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ComponentInstanceImpl extends ReferableBaseObjectImpl implements ComponentInstance { |
| /** |
| * 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 cached value of the '{@link #getType() <em>Type</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getType() |
| * @generated |
| * @ordered |
| */ |
| protected Component type; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ComponentInstanceImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getComponentInstance(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<Tag> getTags() { |
| if (tags == null) { |
| tags = new EObjectResolvingEList<Tag>(Tag.class, this, AmaltheaPackage.COMPONENT_INSTANCE__TAGS); |
| } |
| return tags; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public ISystem getContainingSystem() { |
| if (eContainerFeatureID() != AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM) return null; |
| return (ISystem)eContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ISystem basicGetContainingSystem() { |
| if (eContainerFeatureID() != AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM) return null; |
| return (ISystem)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetContainingSystem(ISystem newContainingSystem, NotificationChain msgs) { |
| msgs = eBasicSetContainer((InternalEObject)newContainingSystem, AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setContainingSystem(ISystem newContainingSystem) { |
| if (newContainingSystem != eInternalContainer() || (eContainerFeatureID() != AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM && newContainingSystem != null)) { |
| if (EcoreUtil.isAncestor(this, newContainingSystem)) |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| if (newContainingSystem != null) |
| msgs = ((InternalEObject)newContainingSystem).eInverseAdd(this, AmaltheaPackage.ISYSTEM__COMPONENT_INSTANCES, ISystem.class, msgs); |
| msgs = basicSetContainingSystem(newContainingSystem, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM, newContainingSystem, newContainingSystem)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Component getType() { |
| if (type != null && type.eIsProxy()) { |
| InternalEObject oldType = (InternalEObject)type; |
| type = (Component)eResolveProxy(oldType); |
| if (type != oldType) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AmaltheaPackage.COMPONENT_INSTANCE__TYPE, oldType, type)); |
| } |
| } |
| return type; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Component basicGetType() { |
| return type; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setType(Component newType) { |
| Component oldType = type; |
| type = newType; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.COMPONENT_INSTANCE__TYPE, oldType, type)); |
| } |
| |
| /** |
| * <!-- 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 NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM: |
| if (eInternalContainer() != null) |
| msgs = eBasicRemoveFromContainer(msgs); |
| return basicSetContainingSystem((ISystem)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 AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM: |
| return basicSetContainingSystem(null, 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_INSTANCE__CONTAINING_SYSTEM: |
| return eInternalContainer().eInverseRemove(this, AmaltheaPackage.ISYSTEM__COMPONENT_INSTANCES, ISystem.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_INSTANCE__TAGS: |
| return getTags(); |
| case AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM: |
| if (resolve) return getContainingSystem(); |
| return basicGetContainingSystem(); |
| case AmaltheaPackage.COMPONENT_INSTANCE__TYPE: |
| if (resolve) return getType(); |
| return basicGetType(); |
| } |
| 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_INSTANCE__TAGS: |
| getTags().clear(); |
| getTags().addAll((Collection<? extends Tag>)newValue); |
| return; |
| case AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM: |
| setContainingSystem((ISystem)newValue); |
| return; |
| case AmaltheaPackage.COMPONENT_INSTANCE__TYPE: |
| setType((Component)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.COMPONENT_INSTANCE__TAGS: |
| getTags().clear(); |
| return; |
| case AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM: |
| setContainingSystem((ISystem)null); |
| return; |
| case AmaltheaPackage.COMPONENT_INSTANCE__TYPE: |
| setType((Component)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.COMPONENT_INSTANCE__TAGS: |
| return tags != null && !tags.isEmpty(); |
| case AmaltheaPackage.COMPONENT_INSTANCE__CONTAINING_SYSTEM: |
| return basicGetContainingSystem() != null; |
| case AmaltheaPackage.COMPONENT_INSTANCE__TYPE: |
| return type != 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_INSTANCE__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_INSTANCE__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_INSTANCE___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_INSTANCE___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_INSTANCE___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_INSTANCE___GET_NAME_PREFIX_SEGMENTS: |
| return getNamePrefixSegments(); |
| } |
| return super.eInvoke(operationID, arguments); |
| } |
| |
| } //ComponentInstanceImpl |