| /** |
| * ******************************************************************************* |
| * Copyright (c) 2015-2021 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.lang.reflect.InvocationTargetException; |
| |
| import org.eclipse.app4mc.amalthea.model.AmaltheaPackage; |
| import org.eclipse.app4mc.amalthea.model.AmaltheaServices2; |
| import org.eclipse.app4mc.amalthea.model.DiscreteValueGaussDistribution; |
| |
| 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; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Discrete Value Gauss Distribution</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.DiscreteValueGaussDistributionImpl#getMean <em>Mean</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.DiscreteValueGaussDistributionImpl#getSd <em>Sd</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class DiscreteValueGaussDistributionImpl extends TruncatedDiscreteValueDistributionImpl implements DiscreteValueGaussDistribution { |
| /** |
| * The default value of the '{@link #getMean() <em>Mean</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getMean() |
| * @generated |
| * @ordered |
| */ |
| protected static final double MEAN_EDEFAULT = 0.0; |
| |
| /** |
| * The cached value of the '{@link #getMean() <em>Mean</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getMean() |
| * @generated |
| * @ordered |
| */ |
| protected double mean = MEAN_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getSd() <em>Sd</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSd() |
| * @generated |
| * @ordered |
| */ |
| protected static final double SD_EDEFAULT = 1.0; |
| |
| /** |
| * The cached value of the '{@link #getSd() <em>Sd</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSd() |
| * @generated |
| * @ordered |
| */ |
| protected double sd = SD_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DiscreteValueGaussDistributionImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getDiscreteValueGaussDistribution(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public double getMean() { |
| return mean; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setMean(double newMean) { |
| double oldMean = mean; |
| mean = newMean; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__MEAN, oldMean, mean)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public double getSd() { |
| return sd; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setSd(double newSd) { |
| double oldSd = sd; |
| sd = newSd; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__SD, oldSd, sd)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Double getAverage() { |
| return AmaltheaServices2.getAverageOfTruncatedNormalDistribution(this.getLowerBound(), this.getUpperBound(), Double.valueOf(this.getMean()), Double.valueOf(this.getSd())); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__MEAN: |
| return getMean(); |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__SD: |
| return getSd(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__MEAN: |
| setMean((Double)newValue); |
| return; |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__SD: |
| setSd((Double)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__MEAN: |
| setMean(MEAN_EDEFAULT); |
| return; |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__SD: |
| setSd(SD_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__MEAN: |
| return mean != MEAN_EDEFAULT; |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION__SD: |
| return sd != SD_EDEFAULT; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { |
| switch (operationID) { |
| case AmaltheaPackage.DISCRETE_VALUE_GAUSS_DISTRIBUTION___GET_AVERAGE: |
| return getAverage(); |
| } |
| return super.eInvoke(operationID, arguments); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (mean: "); |
| result.append(mean); |
| result.append(", sd: "); |
| result.append(sd); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //DiscreteValueGaussDistributionImpl |