| /** |
| * ******************************************************************************* |
| * 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 com.google.common.base.Objects; |
| import java.lang.reflect.InvocationTargetException; |
| |
| import org.eclipse.app4mc.amalthea.model.AmaltheaPackage; |
| import org.eclipse.app4mc.amalthea.model.Voltage; |
| import org.eclipse.app4mc.amalthea.model.VoltageUnit; |
| |
| 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>Voltage</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.VoltageImpl#getValue <em>Value</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.VoltageImpl#getUnit <em>Unit</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class VoltageImpl extends QuantityImpl implements Voltage { |
| /** |
| * The default value of the '{@link #getValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected static final double VALUE_EDEFAULT = 0.0; |
| |
| /** |
| * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected double value = VALUE_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getUnit() <em>Unit</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUnit() |
| * @generated |
| * @ordered |
| */ |
| protected static final VoltageUnit UNIT_EDEFAULT = VoltageUnit._UNDEFINED_; |
| |
| /** |
| * The cached value of the '{@link #getUnit() <em>Unit</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUnit() |
| * @generated |
| * @ordered |
| */ |
| protected VoltageUnit unit = UNIT_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected VoltageImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getVoltage(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public double getValue() { |
| return value; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setValue(double newValue) { |
| double oldValue = value; |
| value = newValue; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.VOLTAGE__VALUE, oldValue, value)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public VoltageUnit getUnit() { |
| return unit; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setUnit(VoltageUnit newUnit) { |
| VoltageUnit oldUnit = unit; |
| unit = newUnit == null ? UNIT_EDEFAULT : newUnit; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.VOLTAGE__UNIT, oldUnit, unit)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| double _value = this.getValue(); |
| String _plus = (Double.valueOf(_value) + " "); |
| String _xifexpression = null; |
| VoltageUnit _unit = this.getUnit(); |
| boolean _equals = Objects.equal(_unit, VoltageUnit._UNDEFINED_); |
| if (_equals) { |
| _xifexpression = "<unit>"; |
| } |
| else { |
| _xifexpression = this.getUnit().getLiteral(); |
| } |
| return (_plus + _xifexpression); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case AmaltheaPackage.VOLTAGE__VALUE: |
| return getValue(); |
| case AmaltheaPackage.VOLTAGE__UNIT: |
| return getUnit(); |
| } |
| 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.VOLTAGE__VALUE: |
| setValue((Double)newValue); |
| return; |
| case AmaltheaPackage.VOLTAGE__UNIT: |
| setUnit((VoltageUnit)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.VOLTAGE__VALUE: |
| setValue(VALUE_EDEFAULT); |
| return; |
| case AmaltheaPackage.VOLTAGE__UNIT: |
| setUnit(UNIT_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.VOLTAGE__VALUE: |
| return value != VALUE_EDEFAULT; |
| case AmaltheaPackage.VOLTAGE__UNIT: |
| return unit != UNIT_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.VOLTAGE___TO_STRING: |
| return toString(); |
| } |
| return super.eInvoke(operationID, arguments); |
| } |
| |
| } //VoltageImpl |