blob: 8169f59d1df8573fa61a754a77e1312cee2fc2cb [file] [log] [blame]
/**
* Copyright (c) 2022 CEA LIST and others.
*
* 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
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* CEA LIST - 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.EObjectResolvingEList;
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;
import org.eclipse.papyrus.aas.HasDataSpecification;
import org.eclipse.papyrus.aas.Reference;
/**
* <!-- 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#getDataSpecification <em>Data Specification</em>}</li>
* <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 cached value of the '{@link #getDataSpecification() <em>Data Specification</em>}' reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getDataSpecification()
* @generated
* @ordered
*/
protected EList<Reference> dataSpecification;
/**
* 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
*/
@Override
public EList<Reference> getDataSpecification() {
if (dataSpecification == null) {
dataSpecification = new EObjectResolvingEList<Reference>(Reference.class, this, AASPackage.ASSET__DATA_SPECIFICATION);
}
return dataSpecification;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public AssetKind getKind() {
return kind;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
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
*/
@Override
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__DATA_SPECIFICATION:
return getDataSpecification();
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__DATA_SPECIFICATION:
getDataSpecification().clear();
getDataSpecification().addAll((Collection<? extends Reference>)newValue);
return;
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__DATA_SPECIFICATION:
getDataSpecification().clear();
return;
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__DATA_SPECIFICATION:
return dataSpecification != null && !dataSpecification.isEmpty();
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 int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
if (baseClass == HasDataSpecification.class) {
switch (derivedFeatureID) {
case AASPackage.ASSET__DATA_SPECIFICATION: return AASPackage.HAS_DATA_SPECIFICATION__DATA_SPECIFICATION;
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 == HasDataSpecification.class) {
switch (baseFeatureID) {
case AASPackage.HAS_DATA_SPECIFICATION__DATA_SPECIFICATION: return AASPackage.ASSET__DATA_SPECIFICATION;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- 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