org.eclipse.viatra.dse.objectives.impl

## Class ModelQueriesGlobalConstraint

- java.lang.Object
- - org.eclipse.viatra.dse.objectives.impl.ModelQueriesGlobalConstraint

- All Implemented Interfaces:
    IGlobalConstraint

      public class ModelQueriesGlobalConstraint
      extends java.lang.Object
      implements IGlobalConstraint

  This global constraint collects a list of VIATRA Query pattern and checks if any of them has a match on along a trajectory. If any of the patterns has a match then it is unsatisfied and the exploration should backtrack.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>>` | `constraints`
    `static java.lang.String` | `GLOBAL_CONSTRAINT`
    `protected java.util.List<ViatraQueryMatcher<? extends IPatternMatch>>` | `matchers`
    `protected java.lang.String` | `name`
    `protected ModelQueryType` | `type`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModelQueriesGlobalConstraint()`
    `ModelQueriesGlobalConstraint(java.util.List<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> constraints)`
    `ModelQueriesGlobalConstraint(java.lang.String name)`
    `ModelQueriesGlobalConstraint(java.lang.String name, java.util.List<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> constraints)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `checkGlobalConstraint(ThreadContext context)` Checks whether the current state satisfies the global constraint.
    `IGlobalConstraint` | `createNew()` Returns an instance of the `IGlobalConstraint`.
    `java.lang.String` | `getName()` Returns the name of the global constraint.
    `void` | `init(ThreadContext context)` Initializes the global constraint.
    `ModelQueriesGlobalConstraint` | `withConstraint(IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> constraint)` Adds a new VIATRA Query pattern.
    `ModelQueriesGlobalConstraint` | `withType(ModelQueryType type)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### GLOBAL_CONSTRAINT

          public static final java.lang.String GLOBAL_CONSTRAINT

      See Also:
        Constant Field Values

    - #### name

          protected java.lang.String name

    - #### constraints

          protected java.util.List<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> constraints

    - #### matchers

          protected java.util.List<ViatraQueryMatcher<? extends IPatternMatch>> matchers

    - #### type

          protected ModelQueryType type

  - ### Constructor Detail

    - #### ModelQueriesGlobalConstraint

          public ModelQueriesGlobalConstraint(java.lang.String name,
                                              java.util.List<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> constraints)

    - #### ModelQueriesGlobalConstraint

          public ModelQueriesGlobalConstraint(java.util.List<IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>>> constraints)

    - #### ModelQueriesGlobalConstraint

          public ModelQueriesGlobalConstraint(java.lang.String name)

    - #### ModelQueriesGlobalConstraint

          public ModelQueriesGlobalConstraint()

  - ### Method Detail

    - #### withConstraint

          public ModelQueriesGlobalConstraint withConstraint(IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> constraint)

      Adds a new VIATRA Query pattern.
      Parameters:
        `constraint` - A VIATRA Query pattern.
      Returns:
        The actual instance to enable builder pattern like usage.

    - #### withType

          public ModelQueriesGlobalConstraint withType(ModelQueryType type)

    - #### getName

          public java.lang.String getName()

      Description copied from interface: `IGlobalConstraint`
      Returns the name of the global constraint.
      Specified by:
        `getName` in interface `IGlobalConstraint`
      Returns:
        The name of the global constraint.

    - #### checkGlobalConstraint

          public boolean checkGlobalConstraint(ThreadContext context)

      Description copied from interface: `IGlobalConstraint`
      Checks whether the current state satisfies the global constraint.
      Specified by:
        `checkGlobalConstraint` in interface `IGlobalConstraint`
      Parameters:
        `context` - The `ThreadContext` which contains the necessary information.
      Returns:
        True if the state is valid and exploration can be continued from the actual state.

    - #### init

          public void init(ThreadContext context)

      Description copied from interface: `IGlobalConstraint`
      Initializes the global constraint. It is called exactly once for every thread starts.
      Specified by:
        `init` in interface `IGlobalConstraint`
      Parameters:
        `context` - The `ThreadContext`.

    - #### createNew

          public IGlobalConstraint createNew()

      Description copied from interface: `IGlobalConstraint`
      Returns an instance of the `IGlobalConstraint`. If it returns the same instance, all the methods has to be thread save as they are called concurrently.
      Specified by:
        `createNew` in interface `IGlobalConstraint`
      Returns:
        An instance of the global constraint.