Operations that are otherwise only available in {@link Class} are implemented to support{@code Type}, for example {@link #isAssignableFrom}, {@link #isArray} and {@link #getComponentType}. It also provides additional utilities such as {@link #getTypes} and {@link #resolveType} etc.
There are three ways to get a {@code TypeToken} instance:
{@code}new TypeToken>()
Note that it's critical that the actual type argument is carried by a subclass. The following code is wrong because it only captures the {@code {@code}class Util static
> listType() { return new TypeToken
>() {}; } } TypeToken
> stringListType = Util.
{@code}abstract class IKnowMyType
{@code TypeToken} is serializable when no type variable is contained in the type.
Note to Guice users: {@code} TypeToken is similar to Guice's {@code TypeLiteral} classexcept that it is serializable and offers numerous additional utility methods. @author Bob Lee @author Sven Mawson @author Ben Yu @since 12.0
|
|
|
|
|
|