Class ConfigQuery


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

      • ConfigQuery

        public ConfigQuery()
    • Method Detail

      • collectVariablesByType

        public static java.util.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,
                                              java.util.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.