Package randoop.types

Class GenericClassType

    • Field Detail

      • rawType

        private Class<?> rawType
        The rawtype of the generic class.
      • parameters

        private List<TypeVariable> parameters
        The type parameters of the generic class.
    • Constructor Detail

      • GenericClassType

        GenericClassType​(Class<?> rawType)
        Creates a GenericClassType for the given raw type.
        Parameters:
        rawType - the Class raw type
    • Method Detail

      • equals

        public boolean equals​(Object obj)

        Checks that the rawtypes are the same. This is sufficient since the type parameters and their bounds can be reconstructed from the Class object. Also, parameters can be distinct depending on how this object is constructed.

        Overrides:
        equals in class ClassOrInterfaceType
        Returns:
        true if two generic classes have the same rawtype, false otherwise
      • getInterfaces

        public List<ClassOrInterfaceType> getInterfaces()
        Returns the interface types directly implemented by this class or interface type. Preserves the order in the reflection method Class.getGenericInterfaces(). If no interfaces are implemented, then returns the empty list.

        Note that this method uses Class.getInterfaces() and does not preserve the relationship between the type parameters of a class and its interfaces, and should not be used when finding supertypes of types represented as InstantiatedType objects.

        Specified by:
        getInterfaces in class ClassOrInterfaceType
        Returns:
        the list of interfaces directly implemented by this type
      • getInterfaces

        List<ClassOrInterfaceType> getInterfaces​(Substitution substitution)
        Return the directly-implemented interface types for this generic class type, instantiated by the given type Substitution.

        This method is not public. It is used when finding the interfaces of an InstantiatedType using InstantiatedType.getInterfaces(), where it is important that the relationship between type variables is preserved. The reflection method Class.getGenericInterfaces() ensures the type variable objects are the same from a class to its interfaces, which allows the use of the same substitution for both types.

        Parameters:
        substitution - the type substitution
        Returns:
        the list of instantiated directly-implemented interface types of this type
      • getRuntimeClass

        public Class<?> getRuntimeClass()
        Description copied from class: Type
        Returns the runtime Class object for this type. For use when reflection is needed.

        Note that type variables and the null reference type do not have a runtime class, and this method will return null in those cases.

        This method should not be confused with the inherited Object.getClass() method, which returns the Class<?> for the Type object, and not of the represented type. For instance, if a Type object t represented the Java type int, then t.getRuntimeClass() would return int.class while t.getClass() would return Type.class.

        Specified by:
        getRuntimeClass in class Type
        Returns:
        the Class that is the runtime representation of the type, or null if this type is a type variable or null reference type
      • getSuperclass

        public ClassOrInterfaceType getSuperclass()
        Return the type for the superclass for this class.

        Note that this method uses Class.getSuperclass() and does not preserve the relationship between the type parameters of a class and its superclass, and should not be used when finding supertypes of types represented as InstantiatedType objects.

        Specified by:
        getSuperclass in class ClassOrInterfaceType
        Returns:
        superclass of this type, or the Object type if this type has no superclass
      • getSuperclass

        ClassOrInterfaceType getSuperclass​(Substitution substitution)
        Returns the superclass type for this generic class type instantiated by the given type Substitution.

        This method is not public. It is used when finding the superclass of an InstantiatedType using InstantiatedType.getSuperclass(), where it is important that the relationship between type variables is preserved. The reflection method Class.getGenericSuperclass() ensures the type variable objects are the same from subclass to superclass, which allows the use of the same substitution for both types.

        Parameters:
        substitution - the type substitution
        Returns:
        the instantiated type
      • instantiate

        public InstantiatedType instantiate​(ReferenceType... typeArguments)
        Creates a type substitution using the given type arguments and applies it to this type.
        Parameters:
        typeArguments - the type arguments
        Returns:
        a type which is this type parameterized by the given type arguments
        See Also:
        substitute(Substitution)
      • instantiate

        public InstantiatedType instantiate​(List<ReferenceType> typeArguments)
        Creates a type substitution using the given type arguments and applies it to this type.
        Parameters:
        typeArguments - the type arguments
        Returns:
        the type that is this type instantiated by the given type arguments
        See Also:
        substitute(Substitution)
      • isAbstract

        public boolean isAbstract()
        Description copied from class: ClassOrInterfaceType
        Indicate whether this class is abstract.
        Specified by:
        isAbstract in class ClassOrInterfaceType
        Returns:
        true if this class is abstract, false otherwise
      • isGeneric

        public boolean isGeneric​(boolean ignoreWildcards)
        Description copied from class: Type
        Indicate whether this type is generic. A type is generic if it has one or more type variables.
        Overrides:
        isGeneric in class ClassOrInterfaceType
        Parameters:
        ignoreWildcards - if true, ignore wildcards; that is, treat wildcards as not making the operation generic
        Returns:
        true if this type is generic, false otherwise
      • isInterface

        public boolean isInterface()
        Description copied from class: Type
        Indicates whether this object is an interface type.
        Overrides:
        isInterface in class Type
        Returns:
        true if this object is an interface type, false otherwise
      • isStatic

        public boolean isStatic()
        Description copied from class: ClassOrInterfaceType
        Indicates whether this class is static.
        Specified by:
        isStatic in class ClassOrInterfaceType
        Returns:
        true if this class is static, false otherwise