Package randoop.types

Class IntersectionTypeBound


  • class IntersectionTypeBound
    extends ParameterBound
    Represents an intersection type bound on a type parameter in a class, interface, method or constructor (see JLS section 4.4). Alternatively, in capture conversion, it may also represent the greatest lower bound of two upper bounds ( JLS section 5.1.10).

    Java requires that an intersection type bound consist of class and interface types, with at most one class, and if there is a class it appears in the conjunction term first. This class preserves the order of the types. In a capture conversion, if both types are classes, one must be a subclass of the other.

    • Field Detail

      • boundList

        private List<ParameterBound> boundList
        The list of type bounds for the intersection bound.
    • Constructor Detail

      • IntersectionTypeBound

        IntersectionTypeBound​(List<ParameterBound> boundList)
        Create an intersection type bound from the list of type bounds.
        Parameters:
        boundList - the list of type bounds
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • substitute

        public IntersectionTypeBound substitute​(Substitution substitution)
        Applies the given substitution to this type bound by replacing type variables.
        Specified by:
        substitute in class ParameterBound
        Parameters:
        substitution - the type substitution
        Returns:
        this bound with the substitution applied to all member bounds
      • getTypeParameters

        public List<TypeVariable> getTypeParameters()
        Returns any type parameters in the type of this bound.
        Specified by:
        getTypeParameters in class ParameterBound
        Returns:
        the list of type variables occurring in all of the type bounds of this intersection bound
      • hasWildcard

        boolean hasWildcard()
        Description copied from class: ParameterBound
        Indicates whether the type of this bound has a wildcard type argument.
        Specified by:
        hasWildcard in class ParameterBound
        Returns:
        true, if this bound has a wildcard argument, and false otherwise
      • hasCaptureVariable

        public boolean hasCaptureVariable()
        Description copied from class: ParameterBound
        Indicates whether the type of this bound has a capture variable.
        Specified by:
        hasCaptureVariable in class ParameterBound
        Returns:
        true iff this bound has a capture variable
      • isGeneric

        public boolean isGeneric​(boolean ignoreWildcards)
        Description copied from class: ParameterBound
        Indicates whether the type of this bound is generic.
        Specified by:
        isGeneric in class ParameterBound
        Parameters:
        ignoreWildcards - if true, ignore wildcards; that is, treat wildcards as not making the operation generic
        Returns:
        true, if this bound type is generic, and false otherwise
      • isLowerBound

        public boolean isLowerBound​(Type otherType,
                                    Substitution subst)
        Indicates whether this bound is a lower bound of the given argument type.

        Specifically, this method checks that the argument type is a subtype of all of the member bounds of this object.

        Specified by:
        isLowerBound in class ParameterBound
        Parameters:
        otherType - the concrete argument type
        subst - the substitution
        Returns:
        true if this bound is a subtype of the given type
      • isObject

        public boolean isObject()
        Indicate whether this bound is Object.

        Determines whether all types in this bound are Object.

        Specified by:
        isObject in class ParameterBound
        Returns:
        true if this bound is Object, false otherwise
      • isSubtypeOf

        public boolean isSubtypeOf​(ParameterBound boundType)
        Indicates whether the type of this bound is a subtype of the type of the given bound.

        This method should never be tested for IntersectionTypeBound. Will fail if assertions are enabled.

        Specified by:
        isSubtypeOf in class ParameterBound
        Parameters:
        boundType - the other bound
        Returns:
        false, always
      • isUpperBound

        public boolean isUpperBound​(Type argType,
                                    Substitution subst)
        Determines if this bound is an upper bound for the argument type.
        Specified by:
        isUpperBound in class ParameterBound
        Parameters:
        argType - the concrete argument type
        subst - the substitution
        Returns:
        true if the argument type satisfies all of the bounds in this intersection type bound
      • isUpperBound

        boolean isUpperBound​(ParameterBound bound,
                             Substitution substitution)
        Indicates whether this bound is an upper bound on the type of the given bound with respect to the type substitution.
        Specified by:
        isUpperBound in class ParameterBound
        Parameters:
        bound - the other bound
        substitution - the type substitution
        Returns:
        true if the argument bound has all of the member bounds of this object as an upper bound