Class CategorialAttributeModification

java.lang.Object
com.amalgamasimulation.studies.core.Modification
com.amalgamasimulation.studies.core.CategorialAttributeModification
All Implemented Interfaces:
VariationModification
Direct Known Subclasses:
ReferenceAttributeModification, TimeSeriesAttributeModification

public class CategorialAttributeModification extends Modification implements VariationModification
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
  • Field Details

  • Constructor Details

    • CategorialAttributeModification

      public CategorialAttributeModification(String fieldName, String variationScopeDescription, Object value, VariationScope variationScope)
      Constructs a new categorial attribute modification.
      Parameters:
      fieldName - the name of the attribute to modify (e.g., "setupDuration")
      variationScopeDescription - a human-readable description of the variation scope, used for reporting or documentation purposes
      value - the constant or multiplier to apply
      variationScope - the VariationScope defining which EObjects the modification applies to (e.g., all objects of a given type, or a specific subset)
  • Method Details

    • fieldName

      public String fieldName()
      Returns the name of the attribute to be modified.
      Returns:
      the field name
    • variationScopeDescription

      public String variationScopeDescription()
      Returns the description of the variation scope.
      Returns:
      the variation scope description
    • value

      public Object value()
      Returns the value to apply. This is either a constant (absolute mode) or a multiplier (relative mode).
      Returns:
      the numeric value used in the modification
    • variationScope

      public VariationScope variationScope()
      Returns the variation scope.
      Returns:
      the variation scope
    • 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 VariationModification
      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
    • makeModification

      protected void makeModification(org.eclipse.emf.ecore.EObject eObject)
    • 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
    • valueString

      public String valueString()
      Specified by:
      valueString in interface VariationModification