Class ConfigurationSaver

java.lang.Object
net.ssehub.easy.varModel.confModel.ConfigurationSaver

public class ConfigurationSaver extends Object
This method is part of the configuration and responsible for saving the values of the configuration inside the Configuration.toProject(boolean) method. The visibility of this class has been relaxed in order to serve as basis for refinements.
Author:
El-Sharkawy, Holger Eichelberger
  • Field Details

  • Constructor Details

  • Method Details

    • getSavedConfiguration

      public Project getSavedConfiguration()
      Returns the project where the values and frozen states are saved to.
      Returns:
      Configuration.getProject() if the constructor was called with ownProject = false, otherwise a new project which imports Configuration.getProject().
    • getConfiguration

      protected Configuration getConfiguration()
      Returns the Configuration, which will currently saved by this saver.
      Returns:
      The configuration to be saved.
    • createProject

      protected Project createProject(Configuration srcConfiguration)
      Creates the project to store the configuration into.
      Parameters:
      srcConfiguration - the configuration to be stored
      Returns:
      the project to store the configuration into
    • addVersion

      protected void addVersion(Project destProject, Configuration srcConfiguration)
      Adds the current version to destProject.
      Parameters:
      destProject - the destination project being set up
      srcConfiguration - the source configuration
    • addImports

      protected void addImports(Project destProject, Configuration srcConfiguration)
      Adds the imports to destProject.
      Parameters:
      destProject - the destination project being set up
      srcConfiguration - the source configuration
    • addLocalVariables

      protected void addLocalVariables(Project destProject, Configuration srcConfiguration)
      Adds local variables to destProject.
      Parameters:
      destProject - the destination project being set up
      srcConfiguration - the source configuration
    • addAttributes

      protected void addAttributes(Project destProject, Configuration srcConfiguration)
      Adds attributes to destProject.
      Parameters:
      destProject - the destination project being set up
      srcConfiguration - the source configuration
    • createAssignmentConstraint

      protected ConstraintSyntaxTree createAssignmentConstraint(Project dstProject, AbstractVariable decl, IDecisionVariable var, Value value)
      Creates an assignment constraint.
      Parameters:
      dstProject - the destination project
      decl - the variable declaration
      var - the configuration variable itself
      value - the value assigned to decl
      Returns:
      the created constraint
    • isSavingEnabled

      protected boolean isSavingEnabled(Project destProject, IDecisionVariable var)
      Returns whether saving this variable (for the destination project destProject) is enabled.
      Parameters:
      destProject - the project being saved
      var - the variable to be checked
      Returns:
      true if saving for var is enabled, false else
    • removedLocalConfigChanges

      private void removedLocalConfigChanges()
      Part of the Configuration.toProject(boolean) method. Removes all local configuration settings of the current project, before current configuration can be merged into the project.
    • processAssignment

      private int processAssignment(Project confProject, StringBuilder errors, AbstractVariable decl, IDecisionVariable var, Value value)
      Processes an assignment.
      Parameters:
      confProject - the project to be modified as a side effect
      errors - the errors collected so far
      decl - the variable declaration
      var - the configuration variable itself
      value - the value assigned to decl
      Returns:
      the new value of code
    • deriveOperand

      protected ConstraintSyntaxTree deriveOperand(AbstractVariable decl, IDecisionVariable var)
      Derives the operand expression for turning a configuration into a project.
      Parameters:
      decl - the variable declaration to start at
      var - the related decision variable
      Returns:
      the constraint syntax tree representing the operand for an assignment
    • toSaveableValue

      protected Value toSaveableValue(IDecisionVariable var, Value value)
      This method escapes special characters for saving them into a file. Should only be called inside the processAssignment(Project, StringBuilder, AbstractVariable, IDecisionVariable, Value) method.
      Parameters:
      var - The variable which belongs to the corresponding value (as t holds the states, which are needed for filtering irrelevant values).
      value - The value which should be saved.
      Returns:
      the value where all problematic characters are escaped.
    • checkState

      private boolean checkState(IAssignmentState state)
      Checks whether the sate (of a variable) should be saved.
      Parameters:
      state - The sate of the current variable to be saved.
      Returns:
      true if the sate should be saved, false otherwise.
    • saveFreezeStates

      protected void saveFreezeStates(Project confProject)
      Part of the Configuration.toProject(boolean) method. This method saves the frozen state of frozen variables.
      Parameters:
      confProject - The project where the states should be saved to.
      See Also:
    • createFreezeBlock

      protected FreezeBlock createFreezeBlock(IFreezable[] freezables, Project parent)
      Creates a freeze block, allowing customization (factory method).
      Parameters:
      freezables - the freezables
      parent - the parent of the freeze block
      Returns:
      the freeze block