Interface Type

All Known Subinterfaces:
AnnotatedType, AnnotationTypeDoc, ClassDoc, ParameterizedType, TypeVariable, WildcardType
@Deprecated(since="9",
            forRemoval=true)
public interface Type
Deprecated, for removal: This API element is subject to removal in a future version.
The declarations in this package have been superseded by those in the package jdk.javadoc.doclet. For more information, see the Migration Guide in the documentation for that package.

Represents a type. A type can be a class or interface, an invocation (like List<String>) of a generic class or interface, a type variable, a wildcard type ("?"), or a primitive data type (like char).

Since:
1.2

Methods

Modifier and Type Method Description
AnnotatedType asAnnotatedType()

Deprecated, for removal: This API element is subject to removal in a future version.

Returns this type as a AnnotatedType if it represents an annotated type.

AnnotationTypeDoc asAnnotationTypeDoc()

Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as an AnnotationTypeDoc if it represents an annotation type.

ClassDoc asClassDoc()

Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a ClassDoc if it represents a class or interface.

ParameterizedType asParameterizedType()

Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a ParameterizedType if it represents an invocation of a generic class or interface.

TypeVariable asTypeVariable()

Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a TypeVariable if it represents a type variable.

WildcardType asWildcardType()

Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a WildcardType if it represents a wildcard type.

String dimension()

Deprecated, for removal: This API element is subject to removal in a future version.

Return the type's dimension information, as a string.

Type getElementType()

Deprecated, for removal: This API element is subject to removal in a future version.

If this type is an array type, return the element type of the array.

boolean isPrimitive()

Deprecated, for removal: This API element is subject to removal in a future version.

Return true if this type represents a primitive type.

String qualifiedTypeName()

Deprecated, for removal: This API element is subject to removal in a future version.

Return qualified name of type excluding any dimension information.

String simpleTypeName()

Deprecated, for removal: This API element is subject to removal in a future version.

Return the simple name of this type excluding any dimension information.

String toString()

Deprecated, for removal: This API element is subject to removal in a future version.

Return a string representation of the type.

String typeName()

Deprecated, for removal: This API element is subject to removal in a future version.

Return unqualified name of type excluding any dimension information.

Methods

typeName

String typeName()
Deprecated, for removal: This API element is subject to removal in a future version.

Return unqualified name of type excluding any dimension information.

For example, a two dimensional array of String returns "String".

Returns:
unqualified name of type excluding any dimension information.

qualifiedTypeName

String qualifiedTypeName()
Deprecated, for removal: This API element is subject to removal in a future version.

Return qualified name of type excluding any dimension information.

For example, a two dimensional array of String returns "java.lang.String".

Returns:
qualified name of this type excluding any dimension information.

simpleTypeName

String simpleTypeName()
Deprecated, for removal: This API element is subject to removal in a future version.

Return the simple name of this type excluding any dimension information. This is the unqualified name of the type, except that for nested types only the identifier of the innermost type is included.

For example, the class Outer.Inner returns "Inner".

Returns:
the simple name of this type excluding any dimension information.
Since:
1.5

dimension

String dimension()
Deprecated, for removal: This API element is subject to removal in a future version.

Return the type's dimension information, as a string.

For example, a two dimensional array of String returns "[][]".

Returns:
the type's dimension information as a string.

toString

String toString()
Deprecated, for removal: This API element is subject to removal in a future version.

Return a string representation of the type. This includes any dimension information and type arguments.

For example, a two dimensional array of String may return "java.lang.String[][]", and the parameterized type List<Integer> may return "java.util.List<java.lang.Integer>".

Overrides:
toString in class Object
Returns:
a string representation of the type.

isPrimitive

boolean isPrimitive()
Deprecated, for removal: This API element is subject to removal in a future version.

Return true if this type represents a primitive type.

Returns:
true if this type represents a primitive type.
Since:
1.5

asClassDoc

ClassDoc asClassDoc()
Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a ClassDoc if it represents a class or interface. Array dimensions are ignored. If this type is a ParameterizedType, TypeVariable, or WildcardType, return the ClassDoc of the type's erasure. If this is an AnnotationTypeDoc, return this as a ClassDoc (but see asAnnotationTypeDoc()). If this is a primitive type, return null.

Returns:
the ClassDoc of this type, or null if it is a primitive type.

asParameterizedType

ParameterizedType asParameterizedType()
Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a ParameterizedType if it represents an invocation of a generic class or interface. Array dimensions are ignored.

Returns:
a ParameterizedType if the type is an invocation of a generic type, or null if it is not.
Since:
1.5

asTypeVariable

TypeVariable asTypeVariable()
Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a TypeVariable if it represents a type variable. Array dimensions are ignored.

Returns:
a TypeVariable if the type is a type variable, or null if it is not.
Since:
1.5

asWildcardType

WildcardType asWildcardType()
Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as a WildcardType if it represents a wildcard type.

Returns:
a WildcardType if the type is a wildcard type, or null if it is not.
Since:
1.5

asAnnotatedType

AnnotatedType asAnnotatedType()
Deprecated, for removal: This API element is subject to removal in a future version.

Returns this type as a AnnotatedType if it represents an annotated type.

Returns:
a AnnotatedType if the type if an annotated type, or null if it is not
Since:
1.8

asAnnotationTypeDoc

AnnotationTypeDoc asAnnotationTypeDoc()
Deprecated, for removal: This API element is subject to removal in a future version.

Return this type as an AnnotationTypeDoc if it represents an annotation type. Array dimensions are ignored.

Returns:
an AnnotationTypeDoc if the type is an annotation type, or null if it is not.
Since:
1.5

getElementType

Type getElementType()
Deprecated, for removal: This API element is subject to removal in a future version.

If this type is an array type, return the element type of the array. Otherwise, return null.

Returns:
a Type representing the element type or null.
Since:
1.8

© 1993, 2020, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/11/docs/api/jdk.javadoc/com/sun/javadoc/Type.html