public final class MoreTypes extends Object
TypeMirror
instances.Modifier and Type | Method and Description |
---|---|
static ArrayType |
asArray(TypeMirror maybeArrayType)
Returns a
ArrayType if the TypeMirror represents a primitive array or
throws an IllegalArgumentException . |
static DeclaredType |
asDeclared(TypeMirror maybeDeclaredType)
Returns a
DeclaredType if the TypeMirror represents a declared type such
as a class, interface, union/compound, or enum or throws an IllegalArgumentException . |
static ErrorType |
asError(TypeMirror maybeErrorType)
Returns a
ExecutableType if the TypeMirror represents an executable type such
as may result from missing code, or bad compiles or throws an IllegalArgumentException . |
static ExecutableType |
asExecutable(TypeMirror maybeExecutableType)
Returns a
ExecutableType if the TypeMirror represents an executable type such
as a method, constructor, or initializer or throws an IllegalArgumentException . |
static NoType |
asNoType(TypeMirror maybeNoType)
Returns a
NoType if the TypeMirror represents an non-type such
as void, or package, etc. |
static NullType |
asNullType(TypeMirror maybeNullType)
Returns a
NullType if the TypeMirror represents the null type
or throws an IllegalArgumentException . |
static PrimitiveType |
asPrimitiveType(TypeMirror maybePrimitiveType)
Returns a
PrimitiveType if the TypeMirror represents a primitive type
or throws an IllegalArgumentException . |
static TypeElement |
asTypeElement(Types types,
TypeMirror mirror) |
static com.google.common.collect.ImmutableSet<TypeElement> |
asTypeElements(Types types,
Iterable<? extends TypeMirror> mirrors) |
static TypeVariable |
asTypeVariable(TypeMirror maybeTypeVariable)
Returns a
TypeVariable if the TypeMirror represents a type variable
or throws an IllegalArgumentException . |
static WildcardType |
asWildcard(WildcardType maybeWildcardType)
Returns a
WildcardType if the TypeMirror represents a wildcard type
or throws an IllegalArgumentException . |
static com.google.common.base.Equivalence<TypeMirror> |
equivalence() |
static boolean |
isTypeOf(Class<?> clazz,
TypeMirror type)
Returns true if the raw type underlying the given
TypeMirror represents the
same raw type as the given Class and throws an IllegalArgumentException if the
TypeMirror does not represent a type that can be referenced by a Class |
static com.google.common.collect.ImmutableSet<TypeElement> |
referencedTypes(TypeMirror type)
Returns the set of types that are referenced by the given
TypeMirror . |
public static com.google.common.base.Equivalence<TypeMirror> equivalence()
public static com.google.common.collect.ImmutableSet<TypeElement> referencedTypes(TypeMirror type)
TypeMirror
.public static TypeElement asTypeElement(Types types, TypeMirror mirror)
public static com.google.common.collect.ImmutableSet<TypeElement> asTypeElements(Types types, Iterable<? extends TypeMirror> mirrors)
public static ArrayType asArray(TypeMirror maybeArrayType)
ArrayType
if the TypeMirror
represents a primitive array or
throws an IllegalArgumentException
.public static DeclaredType asDeclared(TypeMirror maybeDeclaredType)
DeclaredType
if the TypeMirror
represents a declared type such
as a class, interface, union/compound, or enum or throws an IllegalArgumentException
.public static ErrorType asError(TypeMirror maybeErrorType)
ExecutableType
if the TypeMirror
represents an executable type such
as may result from missing code, or bad compiles or throws an IllegalArgumentException
.public static ExecutableType asExecutable(TypeMirror maybeExecutableType)
ExecutableType
if the TypeMirror
represents an executable type such
as a method, constructor, or initializer or throws an IllegalArgumentException
.public static NoType asNoType(TypeMirror maybeNoType)
NoType
if the TypeMirror
represents an non-type such
as void, or package, etc. or throws an IllegalArgumentException
.public static NullType asNullType(TypeMirror maybeNullType)
NullType
if the TypeMirror
represents the null type
or throws an IllegalArgumentException
.public static PrimitiveType asPrimitiveType(TypeMirror maybePrimitiveType)
PrimitiveType
if the TypeMirror
represents a primitive type
or throws an IllegalArgumentException
.public static TypeVariable asTypeVariable(TypeMirror maybeTypeVariable)
TypeVariable
if the TypeMirror
represents a type variable
or throws an IllegalArgumentException
.public static WildcardType asWildcard(WildcardType maybeWildcardType)
WildcardType
if the TypeMirror
represents a wildcard type
or throws an IllegalArgumentException
.public static boolean isTypeOf(Class<?> clazz, TypeMirror type)
TypeMirror
represents the
same raw type as the given Class
and throws an IllegalArgumentException if the
TypeMirror
does not represent a type that can be referenced by a Class
Copyright © 2015 Google, Inc.. All rights reserved.