This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.lang.model.util
interface Types


public interface Types

Utility methods for operating on types.

Compatibility Note: Methods may be added to this interface in future releases of the platform.


Method Summary
 Element

          Returns the element corresponding to a type.
 TypeMirror
asMemberOf(DeclaredType containing, Element element)

          Returns the type of an element when that element is viewed as a member of, or otherwise directly contained by, a given type.
 TypeElement

          Returns the class of a boxed value of a given primitive type.
 TypeMirror

          Applies capture conversion to a type.
 boolean

          Tests whether one type argument contains another.
 List

          Returns the direct supertypes of a type.
 TypeMirror

          Returns the erasure of a type.
 ArrayType
getArrayType(TypeMirror componentType)

          Returns an array type with the specified component type.
 DeclaredType
getDeclaredType(DeclaredType containing, TypeElement typeElem, TypeMirror[] typeArgs)

          Returns the type corresponding to a type element and actual type arguments, given a javax.lang.model.type.DeclaredType.getEnclosingType of which it is a member.
 DeclaredType
getDeclaredType(TypeElement typeElem, TypeMirror[] typeArgs)

          Returns the type corresponding to a type element and actual type arguments.
 NoType

          Returns a pseudo-type used where no actual type is appropriate.
 NullType

          Returns the null type.
 PrimitiveType

          Returns a primitive type.
 WildcardType
getWildcardType(TypeMirror extendsBound, TypeMirror superBound)

          Returns a new wildcard type argument.
 boolean

          Tests whether one type is assignable to another.
 boolean

          Tests whether two objects represent the same type.
 boolean

          Tests whether the signature of one method is a subsignature of another.
 boolean

          Tests whether one type is a subtype of another.
 PrimitiveType

          Returns the type (a primitive type) of unboxed values of a given type.
 

Method Detail

asElement

public Element asElement(TypeMirror t)
Returns the element corresponding to a type. The type may be a {@code DeclaredType} or {@code TypeVariable}. Returns {@code null} if the type is not one with a corresponding element.

Parameters:
t
Returns:
the element corresponding to the given type

asMemberOf

public TypeMirror asMemberOf(DeclaredType containing,
                             Element element)
Returns the type of an element when that element is viewed as a member of, or otherwise directly contained by, a given type. For example, when viewed as a member of the parameterized type {@code Set}, the {@code Set.add} method is an {@code ExecutableType} whose parameter is of type {@code String}.

Parameters:
containing - the containing type
element - the element
Returns:
the type of the element as viewed from the containing type

boxedClass

public TypeElement boxedClass(PrimitiveType p)
Returns the class of a boxed value of a given primitive type. That is, boxing conversion is applied.

Parameters:
p - the primitive type to be converted
Returns:
the class of a boxed value of type {@code p}

capture

public TypeMirror capture(TypeMirror t)
Applies capture conversion to a type.

Parameters:
t - the type to be converted
Returns:
the result of applying capture conversion

contains

public boolean contains(TypeMirror t1,
                        TypeMirror t2)
Tests whether one type argument contains another.

Parameters:
t1 - the first type
t2 - the second type
Returns:
{@code true} if and only if the first type contains the second

directSupertypes

public List directSupertypes(TypeMirror t)
Returns the direct supertypes of a type. The interface types, if any, will appear last in the list.

Parameters:
t - the type being examined
Returns:
the direct supertypes, or an empty list if none

erasure

public TypeMirror erasure(TypeMirror t)
Returns the erasure of a type.

Parameters:
t - the type to be erased
Returns:
the erasure of the given type

getArrayType

public ArrayType getArrayType(TypeMirror componentType)
Returns an array type with the specified component type.

Parameters:
componentType - the component type
Returns:
an array type with the specified component type.

getDeclaredType

public DeclaredType getDeclaredType(DeclaredType containing,
                                    TypeElement typeElem,
                                    TypeMirror[] typeArgs)
Returns the type corresponding to a type element and actual type arguments, given a {@linkplain DeclaredType#getEnclosingType() containing type} of which it is a member. The parameterized type {@code Outer.Inner}, for example, may be constructed by first using {@link #getDeclaredType(TypeElement, TypeMirror...)} to get the type {@code Outer}, and then invoking this method.

If the containing type is a parameterized type, the number of type arguments must equal the number of {@code typeElem}'s formal type parameters. If it is not parameterized or if it is {@code null}, this method is equivalent to {@code getDeclaredType(typeElem, typeArgs)}.

Parameters:
containing - the containing type, or {@code null} if none
typeElem - the type element
typeArgs - the actual type arguments
Returns:
the type corresponding to the type element and actual type arguments, contained within the given type

getDeclaredType

public DeclaredType getDeclaredType(TypeElement typeElem,
                                    TypeMirror[] typeArgs)
Returns the type corresponding to a type element and actual type arguments. Given the type element for {@code Set} and the type mirror for {@code String}, for example, this method may be used to get the parameterized type {@code Set}.

The number of type arguments must either equal the number of the type element's formal type parameters, or must be zero. If zero, and if the type element is generic, then the type element's raw type is returned.

If a parameterized type is being returned, its type element must not be contained within a generic outer class. The parameterized type {@code Outer.Inner}, for example, may be constructed by first using this method to get the type {@code Outer}, and then invoking {@link #getDeclaredType(DeclaredType, TypeElement, TypeMirror...)}.

Parameters:
typeElem - the type element
typeArgs - the actual type arguments
Returns:
the type corresponding to the type element and actual type arguments

getNoType

public NoType getNoType(TypeKind kind)
Returns a pseudo-type used where no actual type is appropriate. The kind of type to return may be either {@link TypeKind#VOID VOID} or {@link TypeKind#NONE NONE}. For packages, use {@link Elements#getPackageElement(CharSequence)}{@code .asType()} instead.

Parameters:
kind - the kind of type to return
Returns:
a pseudo-type of kind {@code VOID} or {@code NONE}

getNullType

public NullType getNullType()
Returns the null type. This is the type of {@code null}.

Returns:
the null type

getPrimitiveType

public PrimitiveType getPrimitiveType(TypeKind kind)
Returns a primitive type.

Parameters:
kind - the kind of primitive type to return
Returns:
a primitive type

getWildcardType

public WildcardType getWildcardType(TypeMirror extendsBound,
                                    TypeMirror superBound)
Returns a new wildcard type argument. Either of the wildcard's bounds may be specified, or neither, but not both.

Parameters:
extendsBound - the extends (upper) bound, or {@code null} if none
superBound - the super (lower) bound, or {@code null} if none
Returns:
a new wildcard

isAssignable

public boolean isAssignable(TypeMirror t1,
                            TypeMirror t2)
Tests whether one type is assignable to another.

Parameters:
t1 - the first type
t2 - the second type
Returns:
{@code true} if and only if the first type is assignable to the second

isSameType

public boolean isSameType(TypeMirror t1,
                          TypeMirror t2)
Tests whether two {@code TypeMirror} objects represent the same type.

Caveat: if either of the arguments to this method represents a wildcard, this method will return false. As a consequence, a wildcard is not the same type as itself. This might be surprising at first, but makes sense once you consider that an example like this must be rejected by the compiler:

 
   {@code List list = new ArrayList();}
   {@code list.add(list.get(0));}
 

Parameters:
t1 - the first type
t2 - the second type
Returns:
{@code true} if and only if the two types are the same

isSubsignature

public boolean isSubsignature(ExecutableType m1,
                              ExecutableType m2)
Tests whether the signature of one method is a subsignature of another.

Parameters:
m1 - the first method
m2 - the second method
Returns:
{@code true} if and only if the first signature is a subsignature of the second

isSubtype

public boolean isSubtype(TypeMirror t1,
                         TypeMirror t2)
Tests whether one type is a subtype of another. Any type is considered to be a subtype of itself.

Parameters:
t1 - the first type
t2 - the second type
Returns:
{@code true} if and only if the first type is a subtype of the second

unboxedType

public PrimitiveType unboxedType(TypeMirror t)
Returns the type (a primitive type) of unboxed values of a given type. That is, unboxing conversion is applied.

Parameters:
t - the type to be unboxed
Returns:
the type of an unboxed value of type {@code t}


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.