Class TypeDescription.Generic.OfNonGenericType.ForLoadedType

    • Field Detail

      • TYPE_CACHE

        private static final java.util.Map<java.lang.Class<?>,​TypeDescription.Generic> TYPE_CACHE
        A cache of generic type descriptions for commonly used types to avoid unnecessary allocations.
      • type

        private final java.lang.Class<?> type
        The type that this instance represents.
    • Constructor Detail

      • ForLoadedType

        public ForLoadedType​(java.lang.Class<?> type)
        Creates a new description of a generic type of a loaded type. This constructor should not normally be used. Use of(Class) instead.
        Parameters:
        type - The represented type.
      • ForLoadedType

        protected ForLoadedType​(java.lang.Class<?> type,
                                TypeDescription.Generic.AnnotationReader annotationReader)
        /** Creates a new description of a generic type of a loaded type.
        Parameters:
        type - The represented type.
        annotationReader - The annotation reader to query for the non-generic type's annotations.
    • Method Detail

      • of

        public static TypeDescription.Generic of​(java.lang.Class<?> type)
        Returns a new immutable generic type description for a loaded type.
        Parameters:
        type - The type to be represented by this generic type description.
        Returns:
        The generic type description representing the given type.
      • asErasure

        public TypeDescription asErasure()
        Returns the erasure of this type. Wildcard types (TypeDefinition.Sort.WILDCARD) do not have a well-defined erasure and cause an IllegalStateException to be thrown.
        Returns:
        The erasure of this type.
      • getOwnerType

        public TypeDescription.Generic getOwnerType()

        Returns the owner type of this type. A type's owner type describes a nested type's declaring type. If it exists, the returned type can be a non-generic or parameterized type. If a class has no declaring type, null is returned.

        An owner type is only well-defined for parameterized types (TypeDefinition.Sort.PARAMETERIZED), for non-generic types (TypeDefinition.Sort.NON_GENERIC) and for generic arrays (TypeDefinition.Sort.GENERIC_ARRAY). For all other types, this method throws an IllegalStateException.

        Returns:
        This type's owner type or null if no owner type exists.
      • getDeclaredAnnotations

        public AnnotationList getDeclaredAnnotations()
        Returns a list of annotations that are declared by this instance.
        Returns:
        A list of declared annotations.
      • represents

        public boolean represents​(java.lang.reflect.Type type)
        Checks if the type described by this instance represents type.
        Specified by:
        represents in interface TypeDefinition
        Overrides:
        represents in class TypeDescription.Generic.OfNonGenericType
        Parameters:
        type - The type of interest.
        Returns:
        true if the type described by this instance represents type.