Interface TypeHierarchy

All Known Implementing Classes:
DefaultTypeHierarchy

public interface TypeHierarchy
Compares AnnotatedTypeMirrors for subtype relationships. See also QualifierHierarchy.
  • Method Details

    • isSubtype

      boolean isSubtype(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype)
      Returns true if subtype is a subtype of or convertible to supertype for all hierarchies present. If the underlying Java type of subtype is not a subtype of or convertible to the underlying Java type of supertype, then the behavior of this method is undefined.

      Ideally, types that require conversions would be converted before isSubtype is called, but instead, isSubtype performs some of these conversions.

      JLS 5.1 specifies 13 categories of conversions.

      3 categories are converted in isSubtype:

      2 happen elsewhere: 7 are not explicitly converted and are treated as though the types are actually subtypes.
      • Identity conversions: type to same type
      • Widening primitive conversions: primitive to primitive (no loss of information, byte to short for example)
      • Narrowing primitive conversions: primitive to primitive (possibly loss of information, short to byte for example)
      • Widening and Narrowing Primitive Conversion: byte to char
      • Widening reference conversions: Upcast
      • Narrowing reference conversions: Downcast
      • Value set conversions: floating-point value from one value set to another without changing its type.
      Parameters:
      subtype - possible subtype
      supertype - possible supertype
      Returns:
      true if subtype is a subtype of supertype for all hierarchies present
    • isSubtypeShallowEffective

      boolean isSubtypeShallowEffective(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype)
      Tests whether the effective annotations of subtype are equal to or are sub-qualifiers of the effective annotations of supertype, according to the type qualifier hierarchy.

      The underlying types of subtype and supertype are not necessarily in a Java subtyping relationship with one another and are only used by this method for special cases when qualifier subtyping depends on the Java basetype.

      Parameters:
      subtype - possible subtype
      supertype - possible supertype
      Returns:
      true iff the effective annotations of subtype are equal to or are sub-qualifiers of the effective annotations of supertype
    • isSubtypeShallowEffective

      boolean isSubtypeShallowEffective(AnnotatedTypeMirror subtype, AnnotatedTypeMirror supertype, AnnotationMirror hierarchy)
      Tests whether the effective annotation in the same hierarchy as hierarchy of subtype are equal to or are sub-qualifiers of the effective annotation of supertype in the same hierarchy as hierarchy, according to the type qualifier hierarchy. Other annotations in subtype and supertype are ignored.

      The underlying types of subtype and supertype are not necessarily in a Java subtyping relationship with one another and are only used by this method for special cases when qualifier subtyping depends on the Java basetype.

      Parameters:
      subtype - possible subtype
      supertype - possible supertype
      hierarchy - an annotation whose hierarchy is used to compare subtype and supertype
      Returns:
      true iff the effective annotation in the same hierarchy as hierarchy of subtype are equal to or are sub-qualifiers of the effective annotation of supertype in the same hierarchy as hierarchy
    • isSubtypeShallowEffective

      boolean isSubtypeShallowEffective(AnnotatedTypeMirror subtype, Collection<? extends AnnotationMirror> superQualifiers)
      Tests whether the effective annotations of subtype are equal to or are sub-qualifiers of superQualifiers, according to the type qualifier hierarchy. Other annotations in subtype are ignored.

      The underlying type of subtype is only used by this method for special cases when qualifier subtyping depends on the Java basetype.

      Parameters:
      subtype - possible subtype
      superQualifiers - possible superQualifiers
      Returns:
      true iff the effective annotations of subtype are equal to or are sub-qualifiers of superQualifiers
    • isSubtypeShallowEffective

      boolean isSubtypeShallowEffective(Collection<? extends AnnotationMirror> subQualifiers, AnnotatedTypeMirror supertype)
      Tests whether subQualifiers are equal to or are sub-qualifiers of the effective annotations of supertype, according to the type qualifier hierarchy. Other annotations in supertype are ignored.

      The underlying type of supertype is used by this method for special cases when qualifier subtyping depends on the Java basetype.

      Parameters:
      subQualifiers - possible subQualifiers
      supertype - possible supertype
      Returns:
      true iff subQualifiers are equal to or are sub-qualifiers of the effective annotations of supertype
    • isSubtypeShallowEffective

      boolean isSubtypeShallowEffective(AnnotatedTypeMirror subtype, AnnotationMirror superQualifier)
      Tests whether the effective annotation of subtype in the same hierarchy as superQualifier is equal to or sub-qualifier of superQualifier, according to the type qualifier hierarchy. The underlying types of subtype is only used by this method for special cases when qualifier subtyping depends on the Java basetype. Other annotations in subtype are ignored.
      Parameters:
      subtype - possible subtype
      superQualifier - possible super qualifier
      Returns:
      true iffhe effective annotation of subtype in the same hierarchy as superQualifier is equal to or sub-qualifier of superQualifier
    • isSubtypeShallowEffective

      boolean isSubtypeShallowEffective(AnnotationMirror subQualifier, AnnotatedTypeMirror supertype)
      Tests whether subQualifier is equal to or sub-qualifier of the effective annotation of supertype in the same hierarchy as subQualifier according to the type qualifier hierarchy. The underlying types of supertype is only used by this method for special cases when qualifier subtyping depends on the Java basetype. Other annotations in supertype are ignored.
      Parameters:
      subQualifier - possible subQualifier
      supertype - possible supertype
      Returns:
      true subQualifier is equal to or sub-qualifier of the effective annotation of supertype in the same hierarchy as subQualifier