blob: be8a9a7dc5af3d10db9f5f2a14bc5b0549a24f44 [file] [log] [blame]
/*****************************************************************************
* 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.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.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.papyrus.aas.AASPackage;
import org.eclipse.papyrus.aas.Asset;
import org.eclipse.papyrus.aas.AssetKind;
import org.eclipse.papyrus.aas.Endpoint;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Asset</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.papyrus.aas.impl.AssetImpl#getKind <em>Kind</em>}</li>
* <li>{@link org.eclipse.papyrus.aas.impl.AssetImpl#getEndpoint <em>Endpoint</em>}</li>
* </ul>
*
* @generated
*/
public class AssetImpl extends IdentifiableImpl implements Asset {
/**
* The default value of the '{@link #getKind() <em>Kind</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getKind()
* @generated
* @ordered
*/
protected static final AssetKind KIND_EDEFAULT = AssetKind.TYPE;
/**
* The cached value of the '{@link #getKind() <em>Kind</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getKind()
* @generated
* @ordered
*/
protected AssetKind kind = KIND_EDEFAULT;
/**
* The cached value of the '{@link #getEndpoint() <em>Endpoint</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getEndpoint()
* @generated
* @ordered
*/
protected EList<Endpoint> endpoint;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected AssetImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return AASPackage.Literals.ASSET;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public AssetKind getKind() {
return kind;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public void setKind(AssetKind newKind) {
AssetKind oldKind = kind;
kind = newKind == null ? KIND_EDEFAULT : newKind;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AASPackage.ASSET__KIND, oldKind, kind));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public EList<Endpoint> getEndpoint() {
if (endpoint == null) {
endpoint = new EObjectContainmentEList<Endpoint>(Endpoint.class, this, AASPackage.ASSET__ENDPOINT);
}
return endpoint;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case AASPackage.ASSET__ENDPOINT:
return ((InternalEList<?>) getEndpoint()).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.ASSET__KIND:
return getKind();
case AASPackage.ASSET__ENDPOINT:
return getEndpoint();
}
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__KIND:
setKind((AssetKind) newValue);
return;
case AASPackage.ASSET__ENDPOINT:
getEndpoint().clear();
getEndpoint().addAll((Collection<? extends Endpoint>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case AASPackage.ASSET__KIND:
setKind(KIND_EDEFAULT);
return;
case AASPackage.ASSET__ENDPOINT:
getEndpoint().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case AASPackage.ASSET__KIND:
return kind != KIND_EDEFAULT;
case AASPackage.ASSET__ENDPOINT:
return endpoint != null && !endpoint.isEmpty();
}
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(" (kind: ");
result.append(kind);
result.append(')');
return result.toString();
}
} // AssetImpl