| /** |
| * ******************************************************************************* |
| * 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 java.util.Map; |
| |
| import org.eclipse.app4mc.amalthea.model.AmaltheaPackage; |
| import org.eclipse.app4mc.amalthea.model.AmaltheaServices2; |
| import org.eclipse.app4mc.amalthea.model.AmaltheaValidations; |
| import org.eclipse.app4mc.amalthea.model.DiscreteValueInterval; |
| |
| import org.eclipse.app4mc.amalthea.model.emf.AmaltheaEObjectImpl; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| 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 Interval</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.DiscreteValueIntervalImpl#getLowerBound <em>Lower Bound</em>}</li> |
| * <li>{@link org.eclipse.app4mc.amalthea.model.impl.DiscreteValueIntervalImpl#getUpperBound <em>Upper Bound</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public abstract class DiscreteValueIntervalImpl extends AmaltheaEObjectImpl implements DiscreteValueInterval { |
| /** |
| * The default value of the '{@link #getLowerBound() <em>Lower Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLowerBound() |
| * @generated |
| * @ordered |
| */ |
| protected static final Long LOWER_BOUND_EDEFAULT = new Long(0L); |
| |
| /** |
| * The cached value of the '{@link #getLowerBound() <em>Lower Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLowerBound() |
| * @generated |
| * @ordered |
| */ |
| protected Long lowerBound = LOWER_BOUND_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getUpperBound() <em>Upper Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUpperBound() |
| * @generated |
| * @ordered |
| */ |
| protected static final Long UPPER_BOUND_EDEFAULT = new Long(0L); |
| |
| /** |
| * The cached value of the '{@link #getUpperBound() <em>Upper Bound</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getUpperBound() |
| * @generated |
| * @ordered |
| */ |
| protected Long upperBound = UPPER_BOUND_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected DiscreteValueIntervalImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return AmaltheaPackage.eINSTANCE.getDiscreteValueInterval(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Long getLowerBound() { |
| return lowerBound; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setLowerBound(Long newLowerBound) { |
| Long oldLowerBound = lowerBound; |
| lowerBound = newLowerBound; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.DISCRETE_VALUE_INTERVAL__LOWER_BOUND, oldLowerBound, lowerBound)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Long getUpperBound() { |
| return upperBound; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setUpperBound(Long newUpperBound) { |
| Long oldUpperBound = upperBound; |
| upperBound = newUpperBound; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, AmaltheaPackage.DISCRETE_VALUE_INTERVAL__UPPER_BOUND, oldUpperBound, upperBound)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Double getAverage() { |
| return AmaltheaServices2.getAverage(this.getLowerBound(), this.getUpperBound()); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean validateInvariants(final DiagnosticChain diagnostics, final Map<Object, Object> context) { |
| return AmaltheaValidations.validateInvariants(this, diagnostics); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL__LOWER_BOUND: |
| return getLowerBound(); |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL__UPPER_BOUND: |
| return getUpperBound(); |
| } |
| 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_INTERVAL__LOWER_BOUND: |
| setLowerBound((Long)newValue); |
| return; |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL__UPPER_BOUND: |
| setUpperBound((Long)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_INTERVAL__LOWER_BOUND: |
| setLowerBound(LOWER_BOUND_EDEFAULT); |
| return; |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL__UPPER_BOUND: |
| setUpperBound(UPPER_BOUND_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL__LOWER_BOUND: |
| return LOWER_BOUND_EDEFAULT == null ? lowerBound != null : !LOWER_BOUND_EDEFAULT.equals(lowerBound); |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL__UPPER_BOUND: |
| return UPPER_BOUND_EDEFAULT == null ? upperBound != null : !UPPER_BOUND_EDEFAULT.equals(upperBound); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| @SuppressWarnings("unchecked") |
| public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException { |
| switch (operationID) { |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL___GET_AVERAGE: |
| return getAverage(); |
| case AmaltheaPackage.DISCRETE_VALUE_INTERVAL___VALIDATE_INVARIANTS__DIAGNOSTICCHAIN_MAP: |
| return validateInvariants((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| } |
| 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(" (lowerBound: "); |
| result.append(lowerBound); |
| result.append(", upperBound: "); |
| result.append(upperBound); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //DiscreteValueIntervalImpl |