Class ConstraintMap


  • public class ConstraintMap
    extends java.lang.Object
    ConstraintMap holds simplified versions of the TUConstraints for ALL type variable for which we are inferring an argument. The ConstraintMap is edited on the fly as the various solvers work (unlike the AF/TU Constraints which are immutable).

    This really consists of these things:

    1. a Map(target => constraints for target)
    2. Methods to easily build up the constraints in the map
    3. A getter for the constraints of individual targets.
    Note: This class, along with TargetConstraints, uses a lot of mutable state and few setters/getters be careful. This choice was made as it makes the resulting code more readable.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPrimaryEqualities​(javax.lang.model.type.TypeVariable target, QualifierHierarchy qualHierarchy, AnnotationMirrorSet annos)
      Add a constraint indicating that target has primary annotations equal to the given annotations.
      void addPrimarySubtypes​(javax.lang.model.type.TypeVariable target, QualifierHierarchy qualHierarchy, AnnotationMirrorSet annos)
      Add a constraint indicating that target's primary annotations are subtypes of the given annotations.
      void addPrimarySupertype​(javax.lang.model.type.TypeVariable target, QualifierHierarchy qualHierarchy, AnnotationMirrorSet annos)
      Add a constraint indicating that target's primary annotations are subtypes of the given annotations.
      void addTargetEquality​(javax.lang.model.type.TypeVariable target, javax.lang.model.type.TypeVariable equivalent, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that the equivalent is equal to target in the given qualifier hierarchies.
      void addTargetSubtype​(javax.lang.model.type.TypeVariable target, javax.lang.model.type.TypeVariable supertype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a subtype of supertype in the given qualifier hierarchies.
      void addTargetSupertype​(javax.lang.model.type.TypeVariable target, javax.lang.model.type.TypeVariable subtype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a supertype of subtype in the given qualifier hierarchies.
      void addTypeEqualities​(javax.lang.model.type.TypeVariable target, AnnotatedTypeMirror type, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is equal to type in the given hierarchies.
      void addTypeSubtype​(javax.lang.model.type.TypeVariable target, AnnotatedTypeMirror supertype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a subtype of supertype in the given qualifier hierarchies.
      void addTypeSupertype​(javax.lang.model.type.TypeVariable target, AnnotatedTypeMirror subtype, AnnotationMirrorSet hierarchies)
      Add a constraint indicating that target is a supertype of subtype in the given qualifier hierarchies.
      TargetConstraints getConstraints​(javax.lang.model.type.TypeVariable target)
      Gets the equality, subtypes, and supertypes constraints for a particular target.
      java.util.Set<javax.lang.model.type.TypeVariable> getTargets()
      Returns the set of all targets passed to the constructor of this constraint map (a target will appear in this list whether or not it has any constraints added).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConstraintMap

        public ConstraintMap​(java.util.Set<javax.lang.model.type.TypeVariable> targets)
    • Method Detail

      • getConstraints

        public TargetConstraints getConstraints​(javax.lang.model.type.TypeVariable target)
        Gets the equality, subtypes, and supertypes constraints for a particular target.
      • getTargets

        public java.util.Set<javax.lang.model.type.TypeVariable> getTargets()
        Returns the set of all targets passed to the constructor of this constraint map (a target will appear in this list whether or not it has any constraints added).
        Returns:
        the set of all targets passed to the constructor of this constraint map (a target will appear in this list whether or not it has any constraints added)
      • addTargetEquality

        public void addTargetEquality​(javax.lang.model.type.TypeVariable target,
                                      javax.lang.model.type.TypeVariable equivalent,
                                      AnnotationMirrorSet hierarchies)
        Add a constraint indicating that the equivalent is equal to target in the given qualifier hierarchies.
      • addPrimaryEqualities

        public void addPrimaryEqualities​(javax.lang.model.type.TypeVariable target,
                                         QualifierHierarchy qualHierarchy,
                                         AnnotationMirrorSet annos)
        Add a constraint indicating that target has primary annotations equal to the given annotations.
      • addTargetSupertype

        public void addTargetSupertype​(javax.lang.model.type.TypeVariable target,
                                       javax.lang.model.type.TypeVariable subtype,
                                       AnnotationMirrorSet hierarchies)
        Add a constraint indicating that target is a supertype of subtype in the given qualifier hierarchies.
        Parameters:
        hierarchies - a set of TOP annotations
      • addTypeSupertype

        public void addTypeSupertype​(javax.lang.model.type.TypeVariable target,
                                     AnnotatedTypeMirror subtype,
                                     AnnotationMirrorSet hierarchies)
        Add a constraint indicating that target is a supertype of subtype in the given qualifier hierarchies.
        Parameters:
        hierarchies - a set of TOP annotations
      • addPrimarySupertype

        public void addPrimarySupertype​(javax.lang.model.type.TypeVariable target,
                                        QualifierHierarchy qualHierarchy,
                                        AnnotationMirrorSet annos)
        Add a constraint indicating that target's primary annotations are subtypes of the given annotations.
      • addTargetSubtype

        public void addTargetSubtype​(javax.lang.model.type.TypeVariable target,
                                     javax.lang.model.type.TypeVariable supertype,
                                     AnnotationMirrorSet hierarchies)
        Add a constraint indicating that target is a subtype of supertype in the given qualifier hierarchies.
        Parameters:
        hierarchies - a set of TOP annotations
      • addTypeSubtype

        public void addTypeSubtype​(javax.lang.model.type.TypeVariable target,
                                   AnnotatedTypeMirror supertype,
                                   AnnotationMirrorSet hierarchies)
        Add a constraint indicating that target is a subtype of supertype in the given qualifier hierarchies.
        Parameters:
        hierarchies - a set of TOP annotations
      • addPrimarySubtypes

        public void addPrimarySubtypes​(javax.lang.model.type.TypeVariable target,
                                       QualifierHierarchy qualHierarchy,
                                       AnnotationMirrorSet annos)
        Add a constraint indicating that target's primary annotations are subtypes of the given annotations.
      • addTypeEqualities

        public void addTypeEqualities​(javax.lang.model.type.TypeVariable target,
                                      AnnotatedTypeMirror type,
                                      AnnotationMirrorSet hierarchies)
        Add a constraint indicating that target is equal to type in the given hierarchies.
        Parameters:
        hierarchies - a set of TOP annotations