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

    Constructors
    Constructor
    Description
    NumericAttributeModification(String typeName, String fieldName, boolean absolute, double value, List<String> objectIdentifiers)
    Constructs a new numeric attribute modification.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns 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.
    boolean
    Indicates whether the modification is absolute or relative.
    boolean
    isApplicable(org.eclipse.emf.ecore.EObject scenario)
    Indicates whether this modification is applicable to a given scenario.
    org.eclipse.emf.ecore.EObject
    modify(org.eclipse.emf.ecore.EObject baseScenario)
    Applies the modification to a given base scenario and returns the modified copy of the base scenario.
    Returns the name of the modification.
    protected Optional<String>
    objectIdentifier(org.eclipse.emf.ecore.EObject eObject)
    To be overridden in subclasses to extract the String ID of a given EObject.
    Returns the EMF type name that this modification applies to.
    double
    Returns the value to apply.

    Methods inherited from class com.amalgamasimulation.studies.core.Modification

    identity, isIdentity, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 - true if the value should replace the current value, false if the current value should be multiplied by it
      value - the constant or multiplier to apply
      objectIdentifiers - list of String identifiers of EObjects to apply the modification to; if empty, all objects of the given type are modified
  • Method Details

    • typeName

      public String typeName()
      Returns the EMF type name that this modification applies to.
      Returns:
      the type name
    • fieldName

      public String 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:
      true if absolute (value is assigned); false if 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:
      value in interface NumericVariationModification
      Returns:
      the numeric value used in the modification
    • getObjectIdentifiers

      public Set<String> 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

      public String name()
      Description copied from class: Modification
      Returns the name of the modification. Used for UI display, logging, or reports.
      Specified by:
      name in interface NumericVariationModification
      Specified by:
      name in class Modification
      Returns:
      the human-readable name of the modification
    • description

      public String description()
      Description copied from class: Modification
      Returns a more detailed description of the modification.
      Specified by:
      description in class Modification
      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: Modification
      Applies 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 using EcoreUtil.copy(EObject) method.
      Specified by:
      modify in class Modification
      Parameters:
      baseScenario - the original EMF scenario to modify
      Returns:
      a new EObject representing the modified scenario
    • objectIdentifier

      protected Optional<String> objectIdentifier(org.eclipse.emf.ecore.EObject eObject)
      To be overridden in subclasses to extract the String ID of a given EObject. By default, returns Optional.empty()
      Parameters:
      eObject - the EMF object
      Returns:
      an Optional containing the String identifier, or Optional.empty() if identifier can not be extracted
    • isApplicable

      public boolean isApplicable(org.eclipse.emf.ecore.EObject scenario)
      Description copied from class: Modification
      Indicates 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:
      isApplicable in class Modification
      Parameters:
      scenario - the scenario to check applicability for
      Returns:
      true if this modification can be applied; otherwise false