Interface TypeDescription

    • Field Detail

      • OBJECT

        static final TypeDescription OBJECT
        A representation of the Object type.
      • STRING

        static final TypeDescription STRING
        A representation of the String type.
      • CLASS

        static final TypeDescription CLASS
        A representation of the Class type.
      • THROWABLE

        static final TypeDescription THROWABLE
        A representation of the Throwable type.
      • VOID

        static final TypeDescription VOID
        A representation of the void non-type.
      • ARRAY_INTERFACES

        static final TypeList.Generic ARRAY_INTERFACES
        A list of interfaces that are implicitly implemented by any array type.
      • UNDEFINED

        static final TypeDescription UNDEFINED
        Represents any undefined property representing a type description that is instead represented as null in order to resemble the Java reflection API which returns null and is intuitive to many Java developers.
    • Method Detail

      • isInstance

        boolean isInstance​(java.lang.Object value)
        Checks if value is an instance of the type represented by this instance.
        Parameters:
        value - The object of interest.
        Returns:
        true if the object is an instance of the type described by this instance.
      • isAssignableFrom

        boolean isAssignableFrom​(java.lang.Class<?> type)
        Checks if this type is assignable from the type described by this instance, for example for class Foo and class Bar extends Foo, this method would return true for Foo.class.isAssignableFrom(Bar.class).
        Parameters:
        type - The type of interest.
        Returns:
        true if this type is assignable from type.
      • isAssignableFrom

        boolean isAssignableFrom​(TypeDescription typeDescription)
        Checks if this type is assignable from the type described by this instance, for example for class Foo and class Bar extends Foo, this method would return true for Foo.class.isAssignableFrom(Bar.class).

         

        Implementations of this methods are allowed to delegate to isAssignableFrom(Class)
        Parameters:
        typeDescription - The type of interest.
        Returns:
        true if this type is assignable from type.
      • isAssignableTo

        boolean isAssignableTo​(java.lang.Class<?> type)
        Checks if this type is assignable from the type described by this instance, for example for class Foo and class Bar extends Foo, this method would return true for Bar.class.isAssignableTo(Foo.class).
        Parameters:
        type - The type of interest.
        Returns:
        true if this type is assignable to type.
      • isAssignableTo

        boolean isAssignableTo​(TypeDescription typeDescription)
        Checks if this type is assignable from the type described by this instance, for example for class Foo and class Bar extends Foo, this method would return true for Bar.class.isAssignableFrom(Foo.class).

         

        Implementations of this methods are allowed to delegate to isAssignableTo(Class)
        Parameters:
        typeDescription - The type of interest.
        Returns:
        true if this type is assignable to type.
      • getDeclaredTypes

        TypeList getDeclaredTypes()
        Returns a list of types that are declared by this type excluding anonymous classes.
        Returns:
        A list of types that are declared within this type.
      • getEnclosingMethod

        MethodDescription getEnclosingMethod()
        Returns a description of the method that encloses this type. If this method is not enclosed by any type or is enclosed by the type initializer, null is returned by this method.
        Returns:
        A description of the enclosing method of this type or null if there is no such method.
      • getEnclosingType

        TypeDescription getEnclosingType()
        Returns a description of this type's enclosing type if any.
        Returns:
        A description of the enclosing type of this type or null if there is no such type.
      • getActualModifiers

        int getActualModifiers​(boolean superFlag)
        Returns the type's actual modifiers as present in the class file. For example, a type cannot be private. but it modifiers might reflect this property nevertheless if a class was defined as a private inner class. The returned modifiers take also into account if the type is marked as Deprecated. Anonymous classes that are enclosed in a static method or the type initializer are additionally marked as final as it is also done by the Java compiler.
        Parameters:
        superFlag - true if the modifier's super flag should be set.
        Returns:
        The type's actual modifiers.
      • getSimpleName

        java.lang.String getSimpleName()
        Returns the simple internalName of this type.
        Returns:
        The simple internalName of this type.
      • getCanonicalName

        java.lang.String getCanonicalName()
        Returns the canonical name of this type if it exists.
        Returns:
        The canonical name of this type. Might be null.
      • isAnonymousClass

        boolean isAnonymousClass()
        Checks if this type description represents an anonymous type.
        Returns:
        true if this type description represents an anonymous type.
      • isLocalClass

        boolean isLocalClass()
        Checks if this type description represents a local type.
        Returns:
        true if this type description represents a local type.
      • isMemberClass

        boolean isMemberClass()
        Checks if this type description represents a member type.
        Returns:
        true if this type description represents a member type.
      • getPackage

        PackageDescription getPackage()
        Returns the package internalName of the type described by this instance.
        Returns:
        The package internalName of the type described by this instance.
      • getInheritedAnnotations

        AnnotationList getInheritedAnnotations()
        Returns the annotations that this type declares or inherits from super types.
        Returns:
        A list of all inherited annotations.
      • isSamePackage

        boolean isSamePackage​(TypeDescription typeDescription)
        Checks if two types are defined in the same package.
        Parameters:
        typeDescription - The type of interest.
        Returns:
        true if this type and the given type are in the same package.
      • isConstantPool

        boolean isConstantPool()
        Checks if instances of this type can be stored in the constant pool of a class. Note that any primitive type that is smaller than an int cannot be stored in the constant pool as those types are represented as int values internally.
        Returns:
        true if instances of this type can be stored in the constant pool of a class.
      • isPrimitiveWrapper

        boolean isPrimitiveWrapper()
        Checks if this type represents a wrapper type for a primitive type. The Void type is not considered to be a wrapper type.
        Returns:
        true if this type represents a wrapper type.
      • isAnnotationReturnType

        boolean isAnnotationReturnType()
        Checks if instances of this type can be returned from an annotation method.
        Returns:
        true if instances of this type can be returned from an annotation method.
      • isAnnotationValue

        boolean isAnnotationValue()
        Checks if instances of this type can be used for describing an annotation value.
        Returns:
        true if instances of this type can be used for describing an annotation value.
      • isAnnotationValue

        boolean isAnnotationValue​(java.lang.Object value)
        Checks if instances of this type can be used for describing the given annotation value.
        Parameters:
        value - The value that is supposed to describe the annotation value for this instance.
        Returns:
        true if instances of this type can be used for describing the given annotation value..
      • isPackageType

        boolean isPackageType()
        Checks if this type represents a class that is a place holder for a package description.
        Returns:
        true if this type represents a package description.
      • getInnerClassCount

        int getInnerClassCount()
        Returns the amount of outer classes this type defines. If this type is not an inner type of another class, 0 is returned.
        Returns:
        The number of outer classes relatively to this type.
      • isInnerClass

        boolean isInnerClass()
        Indicates if this class is an inner class.
        Returns:
        true if this class is an inner class.
      • isNestedClass

        boolean isNestedClass()
        Indicates if this class is a nested class.
        Returns:
        true if this class is a nested class.
      • asBoxed

        TypeDescription asBoxed()
        Returns a description of this type that represents this type as a boxed type for primitive types, unless its void.
        Returns:
        A description of this type in its boxed form.
      • asUnboxed

        TypeDescription asUnboxed()
        Returns a description of this type that represents this type as an unboxed type for boxing types, unless its Void.
        Returns:
        A description of this type in its unboxed form.
      • getDefaultValue

        java.lang.Object getDefaultValue()
        Returns the default value for this type, i.e. the zero value for a primitive type and null for a reference type. For void, null is returned.
        Returns:
        This types default value.