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
  • Constructor Details

    • CategorialAttributeModification

      public CategorialAttributeModification(String typeName, String fieldName, Object 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")
      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
    • 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
    • objectIdentifiers

      public Set<String> objectIdentifiers()
      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 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