org.eclipse.viatra.query.runtime.matchers.planning.helpers

## Class TypeHelper

- java.lang.Object
- - org.eclipse.viatra.query.runtime.matchers.planning.helpers.TypeHelper

-     public class TypeHelper
      extends java.lang.Object

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.Set<TypeJudgement>` | `getDirectJudgements(java.util.Set<PConstraint> constraints, IQueryMetaContext context)` Gets direct judgements reported by constraints.
    `static java.util.Map<PVariable,java.util.Set<TypeJudgement>>` | `inferUnaryTypes(java.util.Set<PConstraint> constraints, IQueryMetaContext context)` Infers unary type information for variables, based on the given constraints.
    `static java.util.Map<PVariable,java.util.Set<IInputKey>>` | `inferUnaryTypesFor(java.lang.Iterable<PVariable> variables, java.util.Map<PVariable,java.util.Set<TypeJudgement>> typeMap)` Collects the type constraints for the specified collection of variables.
    `static java.util.Map<PVariable,java.util.Set<IInputKey>>` | `inferUnaryTypesFor(java.lang.Iterable<PVariable> variables, java.util.Set<PConstraint> constraints, IQueryMetaContext context)` Collects the type constraints for the specified collection of variables.
    `static java.util.Set<TypeJudgement>` | `subsumeTypes(java.util.Set<TypeJudgement> subsumableTypes, java.util.Set<TypeJudgement> subsumingTypes, IQueryMetaContext context)` Calculates a remainder set of types from a larger set, that are not subsumed by a given set of subsuming types.
    `static java.util.Set<TypeJudgement>` | `typeClosure(java.util.Set<TypeJudgement> typesToClose, IQueryMetaContext context)` Calculates the closure of a set of type judgements, with respect to supertyping.
    `static java.util.Set<TypeJudgement>` | `typeClosure(java.util.Set<TypeJudgement> preclosedBaseSet, java.util.Set<TypeJudgement> delta, IQueryMetaContext context)` Calculates the closure of a set of type judgements (with respect to supertyping), where the closure has been calculated before for a given base set, but not for a separate delta set.

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

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

- - ### Method Detail

    - #### inferUnaryTypesFor

          public static java.util.Map<PVariable,java.util.Set<IInputKey>> inferUnaryTypesFor(java.lang.Iterable<PVariable> variables,
                                                                                             java.util.Set<PConstraint> constraints,
                                                                                             IQueryMetaContext context)

      Collects the type constraints for the specified collection of variables. The type constraints consist of the constraints directly enforced on the variable itself, plus all of those that the given variable is unified with through equalities.
      Parameters:
        `variables` - the variables in question
        `constraints` - the constraints in the pattern body
        `context` - the query meta context
      Returns:
        the mapping from variable to set of type constraints
      Since:
        1.6

    - #### inferUnaryTypesFor

          public static java.util.Map<PVariable,java.util.Set<IInputKey>> inferUnaryTypesFor(java.lang.Iterable<PVariable> variables,
                                                                                             java.util.Map<PVariable,java.util.Set<TypeJudgement>> typeMap)

      Collects the type constraints for the specified collection of variables. The type constraints consist of the constraints directly enforced on the variable itself, plus all of those that the given variable is unified with through equalities. The method accepts a type map which is the result of the basic type inference from the `TypeHelper.inferUnaryTypes` method. The purpose of this method is that the type map can be reused across several calls to this method.
      Parameters:
        `variables` - the variables in question
        `typeMap` - the type map of inference results
      Returns:
        the mapping from variable to set of type constraints
      Since:
        1.6

    - #### inferUnaryTypes

          public static java.util.Map<PVariable,java.util.Set<TypeJudgement>> inferUnaryTypes(java.util.Set<PConstraint> constraints,
                                                                                              IQueryMetaContext context)

      Infers unary type information for variables, based on the given constraints. Subsumptions are not taken into account.
      Parameters:
        `constraints` - the set of constraints to extract type info from

    - #### getDirectJudgements

          public static java.util.Set<TypeJudgement> getDirectJudgements(java.util.Set<PConstraint> constraints,
                                                                         IQueryMetaContext context)

      Gets direct judgements reported by constraints. No closure is applied yet.

    - #### typeClosure

          public static java.util.Set<TypeJudgement> typeClosure(java.util.Set<TypeJudgement> typesToClose,
                                                                 IQueryMetaContext context)

      Calculates the closure of a set of type judgements, with respect to supertyping.
      Returns:
        the set of all type judgements in typesToClose and all their direct and indirect supertypes

    - #### typeClosure

          public static java.util.Set<TypeJudgement> typeClosure(java.util.Set<TypeJudgement> preclosedBaseSet,
                                                                 java.util.Set<TypeJudgement> delta,
                                                                 IQueryMetaContext context)

      Calculates the closure of a set of type judgements (with respect to supertyping), where the closure has been calculated before for a given base set, but not for a separate delta set.

      Precondition: the set (typesToClose MINUS delta) is already closed w.r.t. supertyping.

      Returns:
        the set of all type judgements in typesToClose and all their direct and indirect supertypes
      Since:
        1.6

    - #### subsumeTypes

          public static java.util.Set<TypeJudgement> subsumeTypes(java.util.Set<TypeJudgement> subsumableTypes,
                                                                  java.util.Set<TypeJudgement> subsumingTypes,
                                                                  IQueryMetaContext context)

      Calculates a remainder set of types from a larger set, that are not subsumed by a given set of subsuming types.
      Parameters:
        `subsumableTypes` - a set of types from which some may be implied by the subsuming types
        `subsumingTypes` - a set of types that may imply some of the subsuming types
      Returns:
        the collection of types in subsumableTypes that are NOT identical to or supertypes of any type in subsumingTypes.