org.eclipse.viatra.query.runtime.rete.recipes.helper

## Class RecipeRecognizer

- java.lang.Object
- - org.eclipse.viatra.query.runtime.rete.recipes.helper.RecipeRecognizer

-     public class RecipeRecognizer
      extends java.lang.Object

  Stores a set of known canonical recipes, each representing a disjoint equivalence class of recipes, modulo `isEquivalentRecipe(ReteNodeRecipe, ReteNodeRecipe)`.
  Since:
    1.3

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RecipeRecognizer()`
    `RecipeRecognizer(IQueryRuntimeContext runtimeContext)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ReteNodeRecipe` | `canonicalizeRecipe(ReteNodeRecipe recipe)` Ensures that there is an equivalent canonical recipe; if none is known yet, this recipe will be remembered as canonical.
    `boolean` | `isKnownCanonicalRecipe(ReteNodeRecipe recipe)`
    `void` | `makeCanonical(ReteNodeRecipe recipe)` This recipe will be remembered as a canonical recipe.
    `ReteNodeRecipe` | `peekCanonicalRecipe(ReteNodeRecipe recipe)` Recognizes when an equivalent canonical recipe is already known.

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

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

- - ### Constructor Detail

    - #### RecipeRecognizer

          public RecipeRecognizer(IQueryRuntimeContext runtimeContext)

      Parameters:
        `can` - be null; if provided, further equivalences can be detected based on `IQueryRuntimeContext.wrapElement(Object)`
      Since:
        1.6

    - #### RecipeRecognizer

          public RecipeRecognizer()

  - ### Method Detail

    - #### peekCanonicalRecipe

          public ReteNodeRecipe peekCanonicalRecipe(ReteNodeRecipe recipe)

      Recognizes when an equivalent canonical recipe is already known.
      Returns:
        an equivalent canonical recipe, or the null if no known equivalent found

    - #### makeCanonical

          public void makeCanonical(ReteNodeRecipe recipe)

      This recipe will be remembered as a canonical recipe. Method maintains both internal data structures and the equivalence class attribute of the recipe. PRECONDITION: `peekCanonicalRecipe(ReteNodeRecipe)` must return null or the recipe itself

    - #### canonicalizeRecipe

          public ReteNodeRecipe canonicalizeRecipe(ReteNodeRecipe recipe)

      Ensures that there is an equivalent canonical recipe; if none is known yet, this recipe will be remembered as canonical.
      Returns:
        an equivalent canonical recipe; the argument recipe itself (which is made canonical) if no known equivalent found

    - #### isKnownCanonicalRecipe

          public boolean isKnownCanonicalRecipe(ReteNodeRecipe recipe)

      Returns:
        true iff recipe is a canonical recipe