Class ConfigQuery

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

public class ConfigQuery extends Object
Provides an interface to query Configurations.
Author:
El-Sharkawy
  • Constructor Details

    • ConfigQuery

      public ConfigQuery()
  • Method Details

    • possibleValuesForReferences

      static List<ConstraintSyntaxTree> possibleValuesForReferences(Configuration config, Reference refType)
      Calculates possible values (ConstraintSyntaxTree-based) for a given Reference variable.
      Parameters:
      config - The Configuration which contains the queried values.
      refType - The reference for which possible values should be calculated for.
      Returns:
      A maybe empty list of possible values for the given Reference.
    • collectVariablesByType

      public static List<IDecisionVariable> collectVariablesByType(Configuration config, IDatatype type, boolean onlyToplevel)
      Gathers all IDecisionVariables of the given Configuration, which match the specified type.
      Parameters:
      config - The Configuration which contains the queried variables.
      type - The type of which the variables shall be returned, or null if all variables should be returned.
      onlyToplevel - true only top level variables will be returned, false also nested variables will be returned, e.g. nested inside a compound.
      Returns:
      variables The set of variables, which match the given parameters.
    • addVariableByType

      private static void addVariableByType(IDecisionVariable variable, IDatatype type, boolean onlyToplevel, List<IDecisionVariable> variables)
      Recursive part of collectVariablesByType(Configuration, IDatatype, boolean), which searches for (nested) variables.
      Parameters:
      variable - The currently tested variable, which should maybe added.
      type - The type of which the variables shall be returned, or null if all variables should be returned.
      onlyToplevel - true only top level variables will be returned, false also nested variables will be returned, e.g. nested inside a compound.
      variables - The set of variables to be returned (will be changed as a side-effect).
    • toCST

      public static ConstraintSyntaxTree toCST(IDecisionVariable variable) throws ModelQueryException
      Converts an IDecisionVariable of the configuration to a Variable expression, so that it can be used for a value assignment, e.g. for creating a value assignment of a Reference.
      Parameters:
      variable - The variable to be converted, must not be null.
      Returns:
      An absolute expression pointing to the given variable, considering nested variables, e.g., of compounds.
      Throws:
      ModelQueryException - If the given variable could not be resolved to an unambiguous expression, e.g., if the variable is nested inside a Set.