Top Description Inners Fields Constructors Methods
com.google.auto.common

public final Class MoreTypes

extends Object
Class Inheritance
Static Imports
com.google.common.base.Preconditions.checkNotNull, .Preconditions.checkState, javax.lang.model.type.TypeKind.ARRAY, .TypeKind.DECLARED, .TypeKind.EXECUTABLE, .TypeKind.INTERSECTION, .TypeKind.TYPEVAR, .TypeKind.WILDCARD

Utilities related to TypeMirror instances.
Author
Gregory Kick
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private abstract static class
private static class
MoreTypes.CastingUncheckedVisitor

Visitor that tells whether a type is erased, in the sense of castIsUnchecked.

private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ArrayType
asArray(TypeMirror maybeArrayType)

Returns a ArrayType if the TypeMirror represents an array or throws an IllegalArgumentException.

public 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.

public static Element
asElement(TypeMirror typeMirror)

An alternate implementation of Types#asElement that does not require a Types instance with the notable difference that it will throw IllegalArgumentException instead of returning null if the TypeMirror can not be converted to an Element.

public 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.

public 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.

public static IntersectionType
asIntersection(TypeMirror maybeIntersectionType)

Returns an IntersectionType if the TypeMirror represents an intersection-type or throws an IllegalArgumentException.

public static TypeMirror
asMemberOf(Types types, DeclaredType container, VariableElement variable)

Resolves a VariableElement parameter to a method or constructor based on the given container, or a member of a class.

public static NoType
asNoType(TypeMirror maybeNoType)

Returns a NoType if the TypeMirror represents an non-type such as void, or package, etc. or throws an IllegalArgumentException.

public static NullType
asNullType(TypeMirror maybeNullType)

Returns a NullType if the TypeMirror represents the null type or throws an IllegalArgumentException.

public static PrimitiveType
asPrimitiveType(TypeMirror maybePrimitiveType)

Returns a PrimitiveType if the TypeMirror represents a primitive type or throws an IllegalArgumentException.

public static TypeElement
public static ImmutableSet<TypeElement>
asTypeElements(Iterable<? extends TypeMirror> mirrors)

public static TypeVariable
asTypeVariable(TypeMirror maybeTypeVariable)

Returns a TypeVariable if the TypeMirror represents a type variable or throws an IllegalArgumentException.

public static WildcardType
asWildcard(TypeMirror maybeWildcardType)

Returns a WildcardType if the TypeMirror represents a wildcard type or throws an IllegalArgumentException.

private static @Nullable TypeMirror
enclosingType(DeclaredType t)

Returns the type of the innermost enclosing instance, or null if there is none.

private static boolean
private static boolean
equalLists(List<? extends TypeMirror> a, List<? extends TypeMirror> b, Set<MoreTypes.ComparedElements> visiting)

public static Equivalence<TypeMirror>
equivalence()

Returns an Equivalence that can be used to compare types.

private static int
hash(TypeMirror mirror, Set<Element> visiting)

private static int
hashList(List<? extends TypeMirror> mirrors, Set<Element> visiting)

public static boolean
isConversionFromObjectUnchecked(TypeMirror type)

Returns true if casting Object to the given type will elicit an unchecked warning from the compiler.

private static boolean
public static boolean
isType(TypeMirror type)

Returns true if the raw type underlying the given TypeMirror represents a type that can be referenced by a Class.

public static boolean
isTypeOf(final 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

public static Optional<DeclaredType>
nonObjectSuperclass(Types types, Elements elements, DeclaredType type)

Returns the superclass of type, with any type parameters bound by type, or Optional#absent() if type is an interface or Object or its superclass is Object.

public static ImmutableSet<TypeElement>
referencedTypes(TypeMirror type)

Returns the set of types that are referenced by the given TypeMirror.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait