| /** |
| * ******************************************************************************* |
| * 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 java.math.BigInteger; |
| |
| import org.eclipse.app4mc.amalthea.model.AmaltheaPackage; |
| import org.eclipse.app4mc.amalthea.model.AmaltheaServices; |
| import org.eclipse.app4mc.amalthea.model.DataRate; |
| import org.eclipse.app4mc.amalthea.model.DataRateUnit; |
| |
| 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>Data Rate</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.DataRateImpl#getValue <em>Value</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.DataRateImpl#getUnit <em>Unit</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class DataRateImpl extends QuantityImpl implements DataRate { |
| /** |
| * The default value of the '{@link #getValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected static final BigInteger VALUE_EDEFAULT = new BigInteger("0"); |
| |
| /** |
| * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected BigInteger 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 DataRateUnit UNIT_EDEFAULT = DataRateUnit._UNDEFINED_; |
| |
| /** |
| * The cached value of the '{@link #getUnit() <em>Unit</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUnit() |
| * @generated |
| * @ordered |
| */ |
| protected DataRateUnit unit = UNIT_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DataRateImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getDataRate(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public BigInteger getValue() { |
| return value; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setValue(BigInteger newValue) { |
| BigInteger oldValue = value; |
| value = newValue; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.DATA_RATE__VALUE, oldValue, value)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public DataRateUnit getUnit() { |
| return unit; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setUnit(DataRateUnit newUnit) { |
| DataRateUnit oldUnit = unit; |
| unit = newUnit == null ? UNIT_EDEFAULT : newUnit; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.DATA_RATE__UNIT, oldUnit, unit)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| BigInteger _value = this.getValue(); |
| String _plus = (_value + " "); |
| String _xifexpression = null; |
| DataRateUnit _unit = this.getUnit(); |
| boolean _equals = Objects.equal(_unit, DataRateUnit._UNDEFINED_); |
| if (_equals) { |
| _xifexpression = "<unit>"; |
| } |
| else { |
| _xifexpression = this.getUnit().getLiteral().replace("PerSecond", "/s"); |
| } |
| return (_plus + _xifexpression); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int compareTo(final DataRate rate) { |
| return AmaltheaServices.compareDataRates(this, rate); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case AmaltheaPackage.DATA_RATE__VALUE: |
| return getValue(); |
| case AmaltheaPackage.DATA_RATE__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.DATA_RATE__VALUE: |
| setValue((BigInteger)newValue); |
| return; |
| case AmaltheaPackage.DATA_RATE__UNIT: |
| setUnit((DataRateUnit)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.DATA_RATE__VALUE: |
| setValue(VALUE_EDEFAULT); |
| return; |
| case AmaltheaPackage.DATA_RATE__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.DATA_RATE__VALUE: |
| return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); |
| case AmaltheaPackage.DATA_RATE__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.DATA_RATE___TO_STRING: |
| return toString(); |
| case AmaltheaPackage.DATA_RATE___COMPARE_TO__DATARATE: |
| return compareTo((DataRate)arguments.get(0)); |
| } |
| return super.eInvoke(operationID, arguments); |
| } |
| |
| } //DataRateImpl |