Class TypeDescription.AbstractBase

    • Constructor Detail

      • AbstractBase

        public AbstractBase()
    • Method Detail

      • isAssignableFrom

        public boolean isAssignableFrom​(java.lang.Class<?> type)
        Description copied from interface: 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).
        Specified by:
        isAssignableFrom in interface TypeDescription
        Parameters:
        type - The type of interest.
        Returns:
        true if this type is assignable from type.
      • isAssignableFrom

        public boolean isAssignableFrom​(TypeDescription typeDescription)
        Description copied from interface: 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 TypeDescription.isAssignableFrom(Class)
        Specified by:
        isAssignableFrom in interface TypeDescription
        Parameters:
        typeDescription - The type of interest.
        Returns:
        true if this type is assignable from type.
      • isAssignableTo

        public boolean isAssignableTo​(java.lang.Class<?> type)
        Description copied from interface: 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.isAssignableTo(Foo.class).
        Specified by:
        isAssignableTo in interface TypeDescription
        Parameters:
        type - The type of interest.
        Returns:
        true if this type is assignable to type.
      • isAssignableTo

        public boolean isAssignableTo​(TypeDescription typeDescription)
        Description copied from interface: 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 TypeDescription.isAssignableTo(Class)
        Specified by:
        isAssignableTo in interface TypeDescription
        Parameters:
        typeDescription - The type of interest.
        Returns:
        true if this type is assignable to type.
      • isInstance

        public boolean isInstance​(java.lang.Object value)
        Description copied from interface: TypeDescription
        Checks if value is an instance of the type represented by this instance.
        Specified by:
        isInstance in interface TypeDescription
        Parameters:
        value - The object of interest.
        Returns:
        true if the object is an instance of the type described by this instance.
      • isAnnotationValue

        public boolean isAnnotationValue​(java.lang.Object value)
        Description copied from interface: TypeDescription
        Checks if instances of this type can be used for describing the given annotation value.
        Specified by:
        isAnnotationValue in interface TypeDescription
        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..
      • getInternalName

        public java.lang.String getInternalName()
        Description copied from interface: NamedElement.WithRuntimeName
        Returns the internal internalName of this byte code element.
        Specified by:
        getInternalName in interface NamedElement.WithRuntimeName
        Returns:
        The internal internalName of this byte code element as used within the Java class file format.
      • getActualModifiers

        public int getActualModifiers​(boolean superFlag)
        Description copied from interface: TypeDescription
        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.
        Specified by:
        getActualModifiers in interface TypeDescription
        Parameters:
        superFlag - true if the modifier's super flag should be set.
        Returns:
        The type's actual modifiers.
      • getGenericSignature

        public java.lang.String getGenericSignature()
        Description copied from interface: ByteCodeElement
        Returns the generic signature of this byte code element. If this element does not reference generic types or references malformed generic types, null is returned as a signature.
        Specified by:
        getGenericSignature in interface ByteCodeElement
        Returns:
        The generic signature or null if this element is not generic.
      • isSamePackage

        public boolean isSamePackage​(TypeDescription typeDescription)
        Description copied from interface: TypeDescription
        Checks if two types are defined in the same package.
        Specified by:
        isSamePackage in interface TypeDescription
        Parameters:
        typeDescription - The type of interest.
        Returns:
        true if this type and the given type are in the same package.
      • isVisibleTo

        public boolean isVisibleTo​(TypeDescription typeDescription)
        Description copied from interface: ByteCodeElement

        Checks if this element is visible from a given type. Visibility is a wider criteria then accessibility which can be checked by ByteCodeElement.isAccessibleTo(TypeDescription). Visibility allows the invocation of a method on itself or on external instances.

        Note: A method or field might define a signature that includes types that are not visible to a type. Such methods can be legally invoked from this type and can even be implemented as bridge methods by this type. It is however not legal to declare a method with invisible types in its signature that are not bridges what might require additional validation.

        Important: Virtual byte code elements, i.e. virtual methods, are only considered visible if the type they are invoked upon is visible to a given type. The visibility of such virtual members can therefore not be determined by only investigating the invoked method but requires an additional check of the target type.

        Specified by:
        isVisibleTo in interface ByteCodeElement
        Parameters:
        typeDescription - The type which is checked for its visibility of this element.
        Returns:
        true if this element is visible for typeDescription.
      • isAccessibleTo

        public boolean isAccessibleTo​(TypeDescription typeDescription)
        Description copied from interface: ByteCodeElement

        Checks if this element is accessible from a given type. Accessibility is a more narrow criteria then visibility which can be checked by ByteCodeElement.isVisibleTo(TypeDescription). Accessibility allows the invocation of a method on external instances or on itself. Methods that can be invoked from within an instance might however not be considered accessible.

        Note: A method or field might define a signature that includes types that are not visible to a type. Such methods can be legally invoked from this type and can even be implemented as bridge methods by this type. It is however not legal to declare a method with invisible types in its signature that are not bridges what might require additional validation.

        Important: Virtual byte code elements, i.e. virtual methods, are only considered visible if the type they are invoked upon is visible to a given type. The visibility of such virtual members can therefore not be determined by only investigating the invoked method but requires an additional check of the target type.

        Specified by:
        isAccessibleTo in interface ByteCodeElement
        Parameters:
        typeDescription - The type which is checked for its accessibility of this element.
        Returns:
        true if this element is accessible for typeDescription.
      • getActualName

        public java.lang.String getActualName()
        Description copied from interface: NamedElement
        Returns the name of this element as it is found in the source code. If no such name exists, an empty string is returned.
        Specified by:
        getActualName in interface NamedElement
        Returns:
        The name of this element as given in a Java program's source code.
      • isConstantPool

        public boolean isConstantPool()
        Description copied from interface: TypeDescription
        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.
        Specified by:
        isConstantPool in interface TypeDescription
        Returns:
        true if instances of this type can be stored in the constant pool of a class.
      • isPrimitiveWrapper

        public boolean isPrimitiveWrapper()
        Description copied from interface: TypeDescription
        Checks if this type represents a wrapper type for a primitive type. The Void type is not considered to be a wrapper type.
        Specified by:
        isPrimitiveWrapper in interface TypeDescription
        Returns:
        true if this type represents a wrapper type.
      • isAnnotationReturnType

        public boolean isAnnotationReturnType()
        Description copied from interface: TypeDescription
        Checks if instances of this type can be returned from an annotation method.
        Specified by:
        isAnnotationReturnType in interface TypeDescription
        Returns:
        true if instances of this type can be returned from an annotation method.
      • isAnnotationValue

        public boolean isAnnotationValue()
        Description copied from interface: TypeDescription
        Checks if instances of this type can be used for describing an annotation value.
        Specified by:
        isAnnotationValue in interface TypeDescription
        Returns:
        true if instances of this type can be used for describing an annotation value.
      • represents

        public boolean represents​(java.lang.reflect.Type type)
        Description copied from interface: TypeDefinition
        Checks if the type described by this instance represents type.
        Specified by:
        represents in interface TypeDefinition
        Parameters:
        type - The type of interest.
        Returns:
        true if the type described by this instance represents type.
      • getTypeName

        public java.lang.String getTypeName()
        Description copied from interface: TypeDefinition
        Returns the name of the type. For generic types, this name is their Object.toString() representations. For a non-generic type, it is the fully qualified binary name of the type.
        Specified by:
        getTypeName in interface TypeDefinition
        Returns:
        The name of this type.
      • getEnclosingSource

        public TypeVariableSource getEnclosingSource()
        Description copied from interface: TypeVariableSource
        Returns the enclosing source of type variables that are valid in the scope of this type variable source.
        Specified by:
        getEnclosingSource in interface TypeVariableSource
        Returns:
        The enclosing source or null if no such source exists.
      • accept

        public <T> T accept​(TypeVariableSource.Visitor<T> visitor)
        Description copied from interface: TypeVariableSource
        Applies a visitor on this type variable source.
        Specified by:
        accept in interface TypeVariableSource
        Type Parameters:
        T - The visitor's return type.
        Parameters:
        visitor - The visitor to apply.
        Returns:
        The visitor's return value.
      • isPackageType

        public boolean isPackageType()
        Description copied from interface: TypeDescription
        Checks if this type represents a class that is a place holder for a package description.
        Specified by:
        isPackageType in interface TypeDescription
        Returns:
        true if this type represents a package description.
      • isGenerified

        public boolean isGenerified()
        Description copied from interface: TypeVariableSource
        Checks if this type variable source has a generic declaration. This means:
        • A type declares type variables or is an inner class of a type with a generic declaration.
        • A method declares at least one type variable.
        Specified by:
        isGenerified in interface TypeVariableSource
        Returns:
        true if this type code element has a generic declaration.
      • getInnerClassCount

        public int getInnerClassCount()
        Description copied from interface: TypeDescription
        Returns the amount of outer classes this type defines. If this type is not an inner type of another class, 0 is returned.
        Specified by:
        getInnerClassCount in interface TypeDescription
        Returns:
        The number of outer classes relatively to this type.
      • isInnerClass

        public boolean isInnerClass()
        Description copied from interface: TypeDescription
        Indicates if this class is an inner class.
        Specified by:
        isInnerClass in interface TypeDescription
        Returns:
        true if this class is an inner class.
      • isNestedClass

        public boolean isNestedClass()
        Description copied from interface: TypeDescription
        Indicates if this class is a nested class.
        Specified by:
        isNestedClass in interface TypeDescription
        Returns:
        true if this class is a nested class.
      • asBoxed

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

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

        public java.lang.Object getDefaultValue()
        Description copied from interface: TypeDescription
        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.
        Specified by:
        getDefaultValue in interface TypeDescription
        Returns:
        This types default value.
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object