| /** |
| * Copyright (c) 2017 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: |
| * CEA - initial API and implementation and/or initial documentation |
| */ |
| /** |
| */ |
| package org.eclipse.sensinact.studio.resource.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.sensinact.studio.resource.Device; |
| import org.eclipse.sensinact.studio.resource.ResourcePackage; |
| import org.eclipse.sensinact.studio.resource.Service; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Device</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.sensinact.studio.resource.impl.DeviceImpl#getFriendlyName <em>Friendly Name</em>}</li> |
| * <li>{@link org.eclipse.sensinact.studio.resource.impl.DeviceImpl#getService <em>Service</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class DeviceImpl extends NamedElementImpl implements Device { |
| /** |
| * 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 #getService() <em>Service</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getService() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Service> service; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DeviceImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return ResourcePackage.Literals.DEVICE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getFriendlyName() { |
| return friendlyName; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setFriendlyName(String newFriendlyName) { |
| String oldFriendlyName = friendlyName; |
| friendlyName = newFriendlyName; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ResourcePackage.DEVICE__FRIENDLY_NAME, oldFriendlyName, friendlyName)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EList<Service> getService() { |
| if (service == null) { |
| service = new EObjectContainmentEList<Service>(Service.class, this, ResourcePackage.DEVICE__SERVICE); |
| } |
| return service; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case ResourcePackage.DEVICE__SERVICE: |
| return ((InternalEList<?>)getService()).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 ResourcePackage.DEVICE__FRIENDLY_NAME: |
| return getFriendlyName(); |
| case ResourcePackage.DEVICE__SERVICE: |
| return getService(); |
| } |
| 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 ResourcePackage.DEVICE__FRIENDLY_NAME: |
| setFriendlyName((String)newValue); |
| return; |
| case ResourcePackage.DEVICE__SERVICE: |
| getService().clear(); |
| getService().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 ResourcePackage.DEVICE__FRIENDLY_NAME: |
| setFriendlyName(FRIENDLY_NAME_EDEFAULT); |
| return; |
| case ResourcePackage.DEVICE__SERVICE: |
| getService().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case ResourcePackage.DEVICE__FRIENDLY_NAME: |
| return FRIENDLY_NAME_EDEFAULT == null ? friendlyName != null : !FRIENDLY_NAME_EDEFAULT.equals(friendlyName); |
| case ResourcePackage.DEVICE__SERVICE: |
| return service != null && !service.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (friendlyName: "); |
| result.append(friendlyName); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //DeviceImpl |