| /** |
| * ******************************************************************************* |
| * Copyright (c) 2015-2019 Robert Bosch GmbH and others. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Generated using Eclipse EMF |
| * |
| * ******************************************************************************* |
| */ |
| package org.eclipse.app4mc.amalthea.model.impl; |
| |
| import java.util.Collection; |
| |
| import org.eclipse.app4mc.amalthea.model.AmaltheaPackage; |
| import org.eclipse.app4mc.amalthea.model.CPUPercentageMetric; |
| import org.eclipse.app4mc.amalthea.model.CPUPercentageMetricMeasurement; |
| import org.eclipse.app4mc.amalthea.model.IContinuousValueDeviation; |
| import org.eclipse.app4mc.amalthea.model.ProcessingUnit; |
| |
| 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.EDataTypeEList; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>CPU Percentage Metric Measurement</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.CPUPercentageMetricMeasurementImpl#getMetric <em>Metric</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.CPUPercentageMetricMeasurementImpl#getValues <em>Values</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.CPUPercentageMetricMeasurementImpl#getHardwareContext <em>Hardware Context</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.CPUPercentageMetricMeasurementImpl#getStats <em>Stats</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class CPUPercentageMetricMeasurementImpl extends MetricMeasurementImpl implements CPUPercentageMetricMeasurement { |
| /** |
| * The default value of the '{@link #getMetric() <em>Metric</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getMetric() |
| * @generated |
| * @ordered |
| */ |
| protected static final CPUPercentageMetric METRIC_EDEFAULT = CPUPercentageMetric._UNDEFINED_; |
| |
| /** |
| * The cached value of the '{@link #getMetric() <em>Metric</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getMetric() |
| * @generated |
| * @ordered |
| */ |
| protected CPUPercentageMetric metric = METRIC_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getValues() <em>Values</em>}' attribute list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValues() |
| * @generated |
| * @ordered |
| */ |
| protected EList<Double> values; |
| |
| /** |
| * The cached value of the '{@link #getHardwareContext() <em>Hardware Context</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getHardwareContext() |
| * @generated |
| * @ordered |
| */ |
| protected ProcessingUnit hardwareContext; |
| |
| /** |
| * The cached value of the '{@link #getStats() <em>Stats</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getStats() |
| * @generated |
| * @ordered |
| */ |
| protected IContinuousValueDeviation stats; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected CPUPercentageMetricMeasurementImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getCPUPercentageMetricMeasurement(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public CPUPercentageMetric getMetric() { |
| return metric; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setMetric(CPUPercentageMetric newMetric) { |
| CPUPercentageMetric oldMetric = metric; |
| metric = newMetric == null ? METRIC_EDEFAULT : newMetric; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__METRIC, oldMetric, metric)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EList<Double> getValues() { |
| if (values == null) { |
| values = new EDataTypeEList<Double>(Double.class, this, AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__VALUES); |
| } |
| return values; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public ProcessingUnit getHardwareContext() { |
| if (hardwareContext != null && hardwareContext.eIsProxy()) { |
| InternalEObject oldHardwareContext = (InternalEObject)hardwareContext; |
| hardwareContext = (ProcessingUnit)eResolveProxy(oldHardwareContext); |
| if (hardwareContext != oldHardwareContext) { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__HARDWARE_CONTEXT, oldHardwareContext, hardwareContext)); |
| } |
| } |
| return hardwareContext; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ProcessingUnit basicGetHardwareContext() { |
| return hardwareContext; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setHardwareContext(ProcessingUnit newHardwareContext) { |
| ProcessingUnit oldHardwareContext = hardwareContext; |
| hardwareContext = newHardwareContext; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__HARDWARE_CONTEXT, oldHardwareContext, hardwareContext)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public IContinuousValueDeviation getStats() { |
| return stats; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetStats(IContinuousValueDeviation newStats, NotificationChain msgs) { |
| IContinuousValueDeviation oldStats = stats; |
| stats = newStats; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS, oldStats, newStats); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setStats(IContinuousValueDeviation newStats) { |
| if (newStats != stats) { |
| NotificationChain msgs = null; |
| if (stats != null) |
| msgs = ((InternalEObject)stats).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS, null, msgs); |
| if (newStats != null) |
| msgs = ((InternalEObject)newStats).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS, null, msgs); |
| msgs = basicSetStats(newStats, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS, newStats, newStats)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS: |
| return basicSetStats(null, 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 AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__METRIC: |
| return getMetric(); |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__VALUES: |
| return getValues(); |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__HARDWARE_CONTEXT: |
| if (resolve) return getHardwareContext(); |
| return basicGetHardwareContext(); |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS: |
| return getStats(); |
| } |
| 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 AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__METRIC: |
| setMetric((CPUPercentageMetric)newValue); |
| return; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__VALUES: |
| getValues().clear(); |
| getValues().addAll((Collection<? extends Double>)newValue); |
| return; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__HARDWARE_CONTEXT: |
| setHardwareContext((ProcessingUnit)newValue); |
| return; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS: |
| setStats((IContinuousValueDeviation)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__METRIC: |
| setMetric(METRIC_EDEFAULT); |
| return; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__VALUES: |
| getValues().clear(); |
| return; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__HARDWARE_CONTEXT: |
| setHardwareContext((ProcessingUnit)null); |
| return; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS: |
| setStats((IContinuousValueDeviation)null); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__METRIC: |
| return metric != METRIC_EDEFAULT; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__VALUES: |
| return values != null && !values.isEmpty(); |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__HARDWARE_CONTEXT: |
| return hardwareContext != null; |
| case AmaltheaPackage.CPU_PERCENTAGE_METRIC_MEASUREMENT__STATS: |
| return stats != null; |
| } |
| 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(" (metric: "); |
| result.append(metric); |
| result.append(", values: "); |
| result.append(values); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //CPUPercentageMetricMeasurementImpl |