java.lang.Object
org.checkerframework.framework.util.typeinference8.constraint.ConstraintSet
All Implemented Interfaces:
ReductionResult

public class ConstraintSet extends Object implements ReductionResult
A set of constraints and the operations that can be performed on them.
  • Field Details

    • TRUE

      public static final @InternedDistinct ConstraintSet TRUE
      The result given when a constraint set reduces to true.
    • TRUE_ANNO_FAIL

      public static final @InternedDistinct ConstraintSet TRUE_ANNO_FAIL
      The Java types are correct, but the qualifiers are not in the correct relationship. Return this rather than throwing an exception so that type arguments with the correct Java type are still inferred.
    • FALSE

      public static final @InternedDistinct ReductionResult FALSE
      The result given when a constraint set reduces to false.
  • Constructor Details

    • ConstraintSet

      public ConstraintSet(Constraint... constraints)
      Creates a constraint set with constraints.
      Parameters:
      constraints - constraints to add to the newly created set
  • Method Details

    • add

      public void add(Constraint c)
      Adds c to this set, if c isn't already in the list.
      Parameters:
      c - a constraint to add to this set
    • addAll

      public void addAll(ConstraintSet constraintSet)
      Adds all constraints in constraintSet to this constraint set.
      Parameters:
      constraintSet - a set of constraints to add to this set
    • addAll

      public void addAll(Collection<? extends Constraint> constraintSet)
      Adds all constraints in constraintSet to this constraint set.
      Parameters:
      constraintSet - a collection of constraints to add to this set
    • isEmpty

      public boolean isEmpty()
      Return whether or not this constraint set is empty.
      Returns:
      whether or not this constraint set is empty
    • pop

      public Constraint pop()
      Removes and returns the first constraint that was added to this set.
      Returns:
      first constraint that was added to this set
    • remove

      public void remove(ConstraintSet subset)
      Remove all constraints in subset from this constraint set.
      Parameters:
      subset - the set of constraints to remove from this set
    • getClosedSubset

      public ConstraintSet getClosedSubset(Dependencies dependencies)
      A subset of constraints is selected in this constraint set, satisfying the property that, for each constraint, no input variable can influence an output variable of another constraint in this constraint set. (See JLS 18.5.2.2)
      Parameters:
      dependencies - an object describing the dependencies of inference variables
      Returns:
      s a subset of constraints is this constraint set
    • getAllInferenceVariables

      public Set<Variable> getAllInferenceVariables()
      Return all variables mentioned by any constraint in this set.
      Returns:
      all variables mentioned by any constraint in this set
    • getAllInputVariables

      public Set<Variable> getAllInputVariables()
      Return all input variables for all constraints in this set.
      Returns:
      all input variables for all constraints in this set
    • applyInstantiations

      public void applyInstantiations()
      Applies the instantiations to all the constraints in this set.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • reduce

      public BoundSet reduce(Java8InferenceContext context)
      Reduces all the constraints in this set. (See JLS 18.2)
      Parameters:
      context - the context
      Returns:
      the bound set produced by reducing this constraint set
    • reduceOneStep

      public BoundSet reduceOneStep(Java8InferenceContext context)
      Reduce one constraint in this set.
      Parameters:
      context - the context
      Returns:
      the result of reducing one constraint in this set