Class NumericAttributeModification
java.lang.Object
com.amalgamasimulation.studies.core.Modification
com.amalgamasimulation.studies.core.NumericAttributeModification
- All Implemented Interfaces:
NumericVariationModification
public class NumericAttributeModification
extends Modification
implements NumericVariationModification
A
Modification that applies a numeric change to the specified
attribute of selected EMF objects of the specified type within a EMF data
model. The change can be either:
- Absolute: Replaces the current value with the given constant.
- Relative: Multiplies the current value by a factor.
The modification is applied to all EObjects matching the specified
type name, and optionally filtered by a list of object identifiers.
- Author:
- Andrey Malykhanov
-
Constructor Summary
ConstructorsConstructorDescriptionNumericAttributeModification(String typeName, String fieldName, boolean absolute, double value, List<String> objectIdentifiers) Constructs a new numeric attribute modification. -
Method Summary
Modifier and TypeMethodDescriptionReturns a more detailed description of the modification.Returns the name of the attribute to be modified.Returns the set of String identifiers of EObjects that this modification targets.booleanIndicates whether the modification is absolute or relative.booleanisApplicable(org.eclipse.emf.ecore.EObject scenario) Indicates whether this modification is applicable to a given scenario.org.eclipse.emf.ecore.EObjectmodify(org.eclipse.emf.ecore.EObject baseScenario) Applies the modification to a given base scenario and returns the modified copy of the base scenario.name()Returns the name of the modification.objectIdentifier(org.eclipse.emf.ecore.EObject eObject) To be overridden in subclasses to extract the String ID of a given EObject.typeName()Returns the EMF type name that this modification applies to.doublevalue()Returns the value to apply.Methods inherited from class com.amalgamasimulation.studies.core.Modification
identity, isIdentity, toString
-
Constructor Details
-
NumericAttributeModification
public NumericAttributeModification(String typeName, String fieldName, boolean absolute, double value, List<String> objectIdentifiers) Constructs a new numeric attribute modification.- Parameters:
typeName- the name of the EMF type (class or interface) to modify (e.g., "DrillingMachineType")fieldName- the name of the numeric (EInt or EDouble) attribute to modify (e.g., "setupDuration")absolute-trueif the value should replace the current value,falseif the current value should be multiplied by itvalue- the constant or multiplier to applyobjectIdentifiers- list of String identifiers ofEObjects to apply the modification to; if empty, all objects of the given type are modified
-
-
Method Details
-
typeName
Returns the EMF type name that this modification applies to.- Returns:
- the type name
-
fieldName
Returns the name of the attribute to be modified.- Returns:
- the field name
-
isAbsolute
public boolean isAbsolute()Indicates whether the modification is absolute or relative.- Returns:
trueif absolute (value is assigned);falseif relative (value is a multiplier)
-
value
public double value()Returns the value to apply. This is either a constant (absolute mode) or a multiplier (relative mode).- Specified by:
valuein interfaceNumericVariationModification- Returns:
- the numeric value used in the modification
-
getObjectIdentifiers
Returns the set of String identifiers of EObjects that this modification targets. If the set is empty, the modification applies to all objects of the specified type.- Returns:
- an unmodifiable set of identifiers
-
name
Description copied from class:ModificationReturns the name of the modification. Used for UI display, logging, or reports.- Specified by:
namein interfaceNumericVariationModification- Specified by:
namein classModification- Returns:
- the human-readable name of the modification
-
description
Description copied from class:ModificationReturns a more detailed description of the modification.- Specified by:
descriptionin classModification- Returns:
- a human-readable explanation of what this modification does
-
modify
public org.eclipse.emf.ecore.EObject modify(org.eclipse.emf.ecore.EObject baseScenario) Description copied from class:ModificationApplies the modification to a given base scenario and returns the modified copy of the base scenario. Implementations must return a modified deep copy of the input scenario, typically done usingEcoreUtil.copy(EObject)method.- Specified by:
modifyin classModification- Parameters:
baseScenario- the original EMF scenario to modify- Returns:
- a new
EObjectrepresenting the modified scenario
-
objectIdentifier
To be overridden in subclasses to extract the String ID of a given EObject. By default, returnsOptional.empty()- Parameters:
eObject- the EMF object- Returns:
- an
Optionalcontaining the String identifier, orOptional.empty()if identifier can not be extracted
-
isApplicable
public boolean isApplicable(org.eclipse.emf.ecore.EObject scenario) Description copied from class:ModificationIndicates whether this modification is applicable to a given scenario. Applicability means there are certain objects and values that will be changed by this modification. Inapplicable modifications are usually not shown in the UI.- Specified by:
isApplicablein classModification- Parameters:
scenario- the scenario to check applicability for- Returns:
trueif this modification can be applied; otherwisefalse
-