| /***************************************************************************** |
| * Copyright (c) 2020 CEA LIST. |
| * |
| * |
| * 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 |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Saadia Dhouib (CEA LIST) saadia.dhouib@cea.fr - 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.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.papyrus.aas.AASPackage; |
| import org.eclipse.papyrus.aas.Asset; |
| import org.eclipse.papyrus.aas.AssetAdministrationShell; |
| import org.eclipse.papyrus.aas.Security; |
| import org.eclipse.papyrus.aas.Submodel; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Asset Administration Shell</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.papyrus.aas.impl.AssetAdministrationShellImpl#getDerivedFrom <em>Derived From</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.AssetAdministrationShellImpl#getSecurity <em>Security</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.AssetAdministrationShellImpl#getAsset <em>Asset</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.AssetAdministrationShellImpl#getSubmodel <em>Submodel</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.AssetAdministrationShellImpl#getUrl <em>Url</em>}</li> |
| * <li>{@link org.eclipse.papyrus.aas.impl.AssetAdministrationShellImpl#getPort <em>Port</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class AssetAdministrationShellImpl extends IdentifiableImpl implements AssetAdministrationShell { |
| /** |
| * The cached value of the '{@link #getDerivedFrom() <em>Derived From</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getDerivedFrom() |
| * @generated |
| * @ordered |
| */ |
| protected AssetAdministrationShell derivedFrom; |
| |
| /** |
| * The cached value of the '{@link #getSecurity() <em>Security</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getSecurity() |
| * @generated |
| * @ordered |
| */ |
| protected Security security; |
| |
| /** |
| * The cached value of the '{@link #getAsset() <em>Asset</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getAsset() |
| * @generated |
| * @ordered |
| */ |
| protected Asset asset; |
| |
| /** |
| * The cached value of the '{@link #getSubmodel() <em>Submodel</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getSubmodel() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Submodel> submodel; |
| |
| /** |
| * The default value of the '{@link #getUrl() <em>Url</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getUrl() |
| * @generated |
| * @ordered |
| */ |
| protected static final String URL_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getUrl() <em>Url</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getUrl() |
| * @generated |
| * @ordered |
| */ |
| protected String url = URL_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getPort() <em>Port</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getPort() |
| * @generated |
| * @ordered |
| */ |
| protected static final int PORT_EDEFAULT = 0; |
| |
| /** |
| * The cached value of the '{@link #getPort() <em>Port</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @see #getPort() |
| * @generated |
| * @ordered |
| */ |
| protected int port = PORT_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected AssetAdministrationShellImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AASPackage.Literals.ASSET_ADMINISTRATION_SHELL; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public AssetAdministrationShell getDerivedFrom() { |
| if (derivedFrom != null && derivedFrom.eIsProxy()) { |
| InternalEObject oldDerivedFrom = (InternalEObject) derivedFrom; |
| derivedFrom = (AssetAdministrationShell) eResolveProxy(oldDerivedFrom); |
| if (derivedFrom != oldDerivedFrom) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AASPackage.ASSET_ADMINISTRATION_SHELL__DERIVED_FROM, oldDerivedFrom, derivedFrom)); |
| } |
| } |
| return derivedFrom; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public AssetAdministrationShell basicGetDerivedFrom() { |
| return derivedFrom; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public void setDerivedFrom(AssetAdministrationShell newDerivedFrom) { |
| AssetAdministrationShell oldDerivedFrom = derivedFrom; |
| derivedFrom = newDerivedFrom; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.ASSET_ADMINISTRATION_SHELL__DERIVED_FROM, oldDerivedFrom, derivedFrom)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public Security getSecurity() { |
| if (security != null && security.eIsProxy()) { |
| InternalEObject oldSecurity = (InternalEObject) security; |
| security = (Security) eResolveProxy(oldSecurity); |
| if (security != oldSecurity) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AASPackage.ASSET_ADMINISTRATION_SHELL__SECURITY, oldSecurity, security)); |
| } |
| } |
| return security; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public Security basicGetSecurity() { |
| return security; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public void setSecurity(Security newSecurity) { |
| Security oldSecurity = security; |
| security = newSecurity; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.ASSET_ADMINISTRATION_SHELL__SECURITY, oldSecurity, security)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public Asset getAsset() { |
| if (asset != null && asset.eIsProxy()) { |
| InternalEObject oldAsset = (InternalEObject) asset; |
| asset = (Asset) eResolveProxy(oldAsset); |
| if (asset != oldAsset) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AASPackage.ASSET_ADMINISTRATION_SHELL__ASSET, oldAsset, asset)); |
| } |
| } |
| return asset; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public Asset basicGetAsset() { |
| return asset; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public void setAsset(Asset newAsset) { |
| Asset oldAsset = asset; |
| asset = newAsset; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.ASSET_ADMINISTRATION_SHELL__ASSET, oldAsset, asset)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public EList<Submodel> getSubmodel() { |
| if (submodel == null) { |
| submodel = new EObjectResolvingEList<Submodel>(Submodel.class, this, AASPackage.ASSET_ADMINISTRATION_SHELL__SUBMODEL); |
| } |
| return submodel; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public String getUrl() { |
| return url; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public void setUrl(String newUrl) { |
| String oldUrl = url; |
| url = newUrl; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.ASSET_ADMINISTRATION_SHELL__URL, oldUrl, url)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public int getPort() { |
| return port; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public void setPort(int newPort) { |
| int oldPort = port; |
| port = newPort; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.ASSET_ADMINISTRATION_SHELL__PORT, oldPort, port)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__DERIVED_FROM: |
| if (resolve) |
| return getDerivedFrom(); |
| return basicGetDerivedFrom(); |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SECURITY: |
| if (resolve) |
| return getSecurity(); |
| return basicGetSecurity(); |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__ASSET: |
| if (resolve) |
| return getAsset(); |
| return basicGetAsset(); |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SUBMODEL: |
| return getSubmodel(); |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__URL: |
| return getUrl(); |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__PORT: |
| return getPort(); |
| } |
| 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.ASSET_ADMINISTRATION_SHELL__DERIVED_FROM: |
| setDerivedFrom((AssetAdministrationShell) newValue); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SECURITY: |
| setSecurity((Security) newValue); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__ASSET: |
| setAsset((Asset) newValue); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SUBMODEL: |
| getSubmodel().clear(); |
| getSubmodel().addAll((Collection<? extends Submodel>) newValue); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__URL: |
| setUrl((String) newValue); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__PORT: |
| setPort((Integer) newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__DERIVED_FROM: |
| setDerivedFrom((AssetAdministrationShell) null); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SECURITY: |
| setSecurity((Security) null); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__ASSET: |
| setAsset((Asset) null); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SUBMODEL: |
| getSubmodel().clear(); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__URL: |
| setUrl(URL_EDEFAULT); |
| return; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__PORT: |
| setPort(PORT_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__DERIVED_FROM: |
| return derivedFrom != null; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SECURITY: |
| return security != null; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__ASSET: |
| return asset != null; |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__SUBMODEL: |
| return submodel != null && !submodel.isEmpty(); |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__URL: |
| return URL_EDEFAULT == null ? url != null : !URL_EDEFAULT.equals(url); |
| case AASPackage.ASSET_ADMINISTRATION_SHELL__PORT: |
| return port != PORT_EDEFAULT; |
| } |
| 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(" (url: "); |
| result.append(url); |
| result.append(", port: "); |
| result.append(port); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // AssetAdministrationShellImpl |