| /** |
| * ******************************************************************************* |
| * Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Regent L'Archeveque - initial API and implementation |
| * |
| * SPDX-License-Identifier: EPL-1.0 |
| * ******************************************************************************* |
| */ |
| package org.eclipse.apogy.core.environment.earth.orbit.planner.impl; |
| |
| import org.eclipse.apogy.core.environment.earth.orbit.planner.ApogyCoreEnvironmentEarthOrbitPlannerPackage; |
| import org.eclipse.apogy.core.environment.earth.orbit.planner.CostFunctionState; |
| import org.eclipse.apogy.core.environment.earth.orbit.planner.StatefulCostFunctionMapEntryValue; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Stateful Cost Function Map Entry Value</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.apogy.core.environment.earth.orbit.planner.impl.StatefulCostFunctionMapEntryValueImpl#getState <em>State</em>}</li> |
| * <li>{@link org.eclipse.apogy.core.environment.earth.orbit.planner.impl.StatefulCostFunctionMapEntryValueImpl#getCost <em>Cost</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class StatefulCostFunctionMapEntryValueImpl extends MinimalEObjectImpl.Container implements StatefulCostFunctionMapEntryValue { |
| /** |
| * The cached value of the '{@link #getState() <em>State</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getState() |
| * @generated |
| * @ordered |
| */ |
| protected CostFunctionState state; |
| |
| /** |
| * The default value of the '{@link #getCost() <em>Cost</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getCost() |
| * @generated |
| * @ordered |
| */ |
| protected static final double COST_EDEFAULT = 0.0; |
| |
| /** |
| * The cached value of the '{@link #getCost() <em>Cost</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getCost() |
| * @generated |
| * @ordered |
| */ |
| protected double cost = COST_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected StatefulCostFunctionMapEntryValueImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return ApogyCoreEnvironmentEarthOrbitPlannerPackage.Literals.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public CostFunctionState getState() { |
| return state; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetState(CostFunctionState newState, NotificationChain msgs) { |
| CostFunctionState oldState = state; |
| state = newState; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE, oldState, newState); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setState(CostFunctionState newState) { |
| if (newState != state) { |
| NotificationChain msgs = null; |
| if (state != null) |
| msgs = ((InternalEObject)state).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE, null, msgs); |
| if (newState != null) |
| msgs = ((InternalEObject)newState).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE, null, msgs); |
| msgs = basicSetState(newState, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE, newState, newState)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public double getCost() { |
| return cost; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setCost(double newCost) { |
| double oldCost = cost; |
| cost = newCost; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__COST, oldCost, cost)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE: |
| return basicSetState(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 ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE: |
| return getState(); |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__COST: |
| return getCost(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE: |
| setState((CostFunctionState)newValue); |
| return; |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__COST: |
| setCost((Double)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE: |
| setState((CostFunctionState)null); |
| return; |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__COST: |
| setCost(COST_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__STATE: |
| return state != null; |
| case ApogyCoreEnvironmentEarthOrbitPlannerPackage.STATEFUL_COST_FUNCTION_MAP_ENTRY_VALUE__COST: |
| return cost != COST_EDEFAULT; |
| } |
| 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(" (cost: "); |
| result.append(cost); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //StatefulCostFunctionMapEntryValueImpl |