Stay organized with collections
Save and categorize content based on your preferences.
ParameterizedType
public
interface
ParameterizedType
implements
Type
java.lang.reflect.ParameterizedType
|
ParameterizedType represents a parameterized type such as
Collection<String>.
A parameterized type is created the first time it is needed by a
reflective method, as specified in this package. When a
parameterized type p is created, the generic type declaration that
p instantiates is resolved, and all type arguments of p are created
recursively. See TypeVariable
for details on the creation process for type
variables. Repeated creation of a parameterized type has no effect.
Instances of classes that implement this interface must implement
an equals() method that equates any two instances that share the
same generic type declaration and have equal type parameters.
Summary
Public methods |
abstract
Type[]
|
getActualTypeArguments()
Returns an array of Type objects representing the actual type
arguments to this type.
|
abstract
Type
|
getOwnerType()
Returns a Type object representing the type that this type
is a member of.
|
abstract
Type
|
getRawType()
Returns the Type object representing the class or interface
that declared this type.
|
Public methods
getActualTypeArguments
public abstract Type[] getActualTypeArguments ()
Returns an array of Type
objects representing the actual type
arguments to this type.
Note that in some cases, the returned array be empty. This can occur
if this type represents a non-parameterized type nested within
a parameterized type.
Returns |
Type[] |
an array of Type objects representing the actual type
arguments to this type |
getOwnerType
public abstract Type getOwnerType ()
Returns a Type
object representing the type that this type
is a member of. For example, if this type is O<T>.I<S>
,
return a representation of O<T>
.
If this type is a top-level type, null
is returned.
Returns |
Type |
a Type object representing the type that
this type is a member of. If this type is a top-level type,
null is returned |
getRawType
public abstract Type getRawType ()
Returns the Type
object representing the class or interface
that declared this type.
Returns |
Type |
the Type object representing the class or interface
that declared this type |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ParameterizedType\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nParameterizedType\n=================\n\n\n`\npublic\n\n\ninterface\nParameterizedType\n`\n\n\n`\n\n\nimplements\n\n`[Type](/reference/java/lang/reflect/Type)`\n\n\n`\n\n|-------------------------------------|\n| java.lang.reflect.ParameterizedType |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nParameterizedType represents a parameterized type such as\nCollection\\\u003cString\\\u003e.\n\nA parameterized type is created the first time it is needed by a\nreflective method, as specified in this package. When a\nparameterized type p is created, the generic type declaration that\np instantiates is resolved, and all type arguments of p are created\nrecursively. See [TypeVariable](/reference/java/lang/reflect/TypeVariable) for details on the creation process for type\nvariables. Repeated creation of a parameterized type has no effect.\n\nInstances of classes that implement this interface must implement\nan equals() method that equates any two instances that share the\nsame generic type declaration and have equal type parameters.\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract `[Type[]](/reference/java/lang/reflect/Type) | ` `[getActualTypeArguments](/reference/java/lang/reflect/ParameterizedType#getActualTypeArguments())`() ` Returns an array of `Type` objects representing the actual type arguments to this type. |\n| ` abstract `[Type](/reference/java/lang/reflect/Type) | ` `[getOwnerType](/reference/java/lang/reflect/ParameterizedType#getOwnerType())`() ` Returns a `Type` object representing the type that this type is a member of. |\n| ` abstract `[Type](/reference/java/lang/reflect/Type) | ` `[getRawType](/reference/java/lang/reflect/ParameterizedType#getRawType())`() ` Returns the `Type` object representing the class or interface that declared this type. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.lang.reflect.Type](/reference/java/lang/reflect/Type)` ` |--------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default `[String](/reference/java/lang/String) | ` `[getTypeName](/reference/java/lang/reflect/Type#getTypeName())`() ` Returns a string describing this type, including information about any type parameters. | ||\n\nPublic methods\n--------------\n\n### getActualTypeArguments\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Type[] getActualTypeArguments ()\n```\n\nReturns an array of `Type` objects representing the actual type\narguments to this type.\n\nNote that in some cases, the returned array be empty. This can occur\nif this type represents a non-parameterized type nested within\na parameterized type.\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------------------------------------|---------------------------------------------------------------------------------------|\n| [Type[]](/reference/java/lang/reflect/Type) | an array of `Type` objects representing the actual type arguments to this type \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|\n| [TypeNotPresentException](/reference/java/lang/TypeNotPresentException) | if any of the actual type arguments refers to a non-existent type declaration |\n| [MalformedParameterizedTypeException](/reference/java/lang/reflect/MalformedParameterizedTypeException) | if any of the actual type parameters refer to a parameterized type that cannot be instantiated for any reason |\n\n### getOwnerType\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Type getOwnerType ()\n```\n\nReturns a `Type` object representing the type that this type\nis a member of. For example, if this type is `O\u003cT\u003e.I\u003cS\u003e`,\nreturn a representation of `O\u003cT\u003e`.\n\nIf this type is a top-level type, `null` is returned.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|\n| [Type](/reference/java/lang/reflect/Type) | a `Type` object representing the type that this type is a member of. If this type is a top-level type, `null` is returned \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|\n| [TypeNotPresentException](/reference/java/lang/TypeNotPresentException) | if the owner type refers to a non-existent type declaration |\n| [MalformedParameterizedTypeException](/reference/java/lang/reflect/MalformedParameterizedTypeException) | if the owner type refers to a parameterized type that cannot be instantiated for any reason |\n\n### getRawType\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Type getRawType ()\n```\n\nReturns the `Type` object representing the class or interface\nthat declared this type.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------------------------------------------|--------------------------------------------------------------------------------------|\n| [Type](/reference/java/lang/reflect/Type) | the `Type` object representing the class or interface that declared this type \u003cbr /\u003e |"]]