| /** |
| * Copyright (c) 2018 CEA |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Jérémie Tatibouet (CEA) jeremie.tatibouet@cea.fr - Initial API and implementation |
| * Benoit Maggi (CEA) benoit.maggi@cea.fr - Initial API and implementation |
| * Shuai Li (CEA) shuai.li@cea.fr - Integration of sensiNact and Web of Things Thing Description |
| * |
| */ |
| package org.eclipse.papyrus.iotml.sensinact.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.impl.ENotificationImpl; |
| |
| import org.eclipse.emf.ecore.util.EObjectResolvingEList; |
| |
| import org.eclipse.papyrus.iotml.sensinact.SensinactPackage; |
| import org.eclipse.papyrus.iotml.sensinact.Service; |
| import org.eclipse.papyrus.iotml.sensinact.ServiceProvider; |
| |
| import org.eclipse.papyrus.iotml.software.artefact.impl.VirtualEntityImpl; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Service Provider</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.papyrus.iotml.sensinact.impl.ServiceProviderImpl#getFriendlyName <em>Friendly Name</em>}</li> |
| * <li>{@link org.eclipse.papyrus.iotml.sensinact.impl.ServiceProviderImpl#getServices <em>Services</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ServiceProviderImpl extends VirtualEntityImpl implements ServiceProvider { |
| /** |
| * The default value of the '{@link #getFriendlyName() <em>Friendly Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFriendlyName() |
| * @generated |
| * @ordered |
| */ |
| protected static final String FRIENDLY_NAME_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getFriendlyName() <em>Friendly Name</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getFriendlyName() |
| * @generated |
| * @ordered |
| */ |
| protected String friendlyName = FRIENDLY_NAME_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getServices() <em>Services</em>}' reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getServices() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Service> services; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ServiceProviderImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return SensinactPackage.Literals.SERVICE_PROVIDER; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String getFriendlyName() { |
| return friendlyName; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setFriendlyName(String newFriendlyName) { |
| String oldFriendlyName = friendlyName; |
| friendlyName = newFriendlyName; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, SensinactPackage.SERVICE_PROVIDER__FRIENDLY_NAME, oldFriendlyName, friendlyName)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<Service> getServices() { |
| if (services == null) { |
| services = new EObjectResolvingEList<Service>(Service.class, this, SensinactPackage.SERVICE_PROVIDER__SERVICES); |
| } |
| return services; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case SensinactPackage.SERVICE_PROVIDER__FRIENDLY_NAME: |
| return getFriendlyName(); |
| case SensinactPackage.SERVICE_PROVIDER__SERVICES: |
| return getServices(); |
| } |
| 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 SensinactPackage.SERVICE_PROVIDER__FRIENDLY_NAME: |
| setFriendlyName((String)newValue); |
| return; |
| case SensinactPackage.SERVICE_PROVIDER__SERVICES: |
| getServices().clear(); |
| getServices().addAll((Collection<? extends Service>)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case SensinactPackage.SERVICE_PROVIDER__FRIENDLY_NAME: |
| setFriendlyName(FRIENDLY_NAME_EDEFAULT); |
| return; |
| case SensinactPackage.SERVICE_PROVIDER__SERVICES: |
| getServices().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case SensinactPackage.SERVICE_PROVIDER__FRIENDLY_NAME: |
| return FRIENDLY_NAME_EDEFAULT == null ? friendlyName != null : !FRIENDLY_NAME_EDEFAULT.equals(friendlyName); |
| case SensinactPackage.SERVICE_PROVIDER__SERVICES: |
| return services != null && !services.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(" (friendlyName: "); |
| result.append(friendlyName); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ServiceProviderImpl |