public final class TypesUtils
extends java.lang.Object
TypeMirror
s.Modifier and Type | Method and Description |
---|---|
static boolean |
areSamePrimitiveTypes(javax.lang.model.type.TypeMirror left,
javax.lang.model.type.TypeMirror right)
Returns true iff the arguments are both the same primitive types.
|
static javax.lang.model.type.ArrayType |
createArrayType(javax.lang.model.util.Types types,
javax.lang.model.type.TypeMirror componentType)
Returns an
ArrayType with elements of type componentType . |
static javax.lang.model.type.TypeMirror |
findConcreteUpperBound(javax.lang.model.type.TypeMirror boundedType)
Given a bounded type (wildcard or typevar) get the concrete type of its upper bound.
|
static javax.lang.model.element.Name |
getQualifiedName(javax.lang.model.type.DeclaredType type)
Gets the fully qualified name for a provided type.
|
static boolean |
isAnonymous(javax.lang.model.type.TypeMirror type)
Returns true iff the argument is an anonymous type.
|
static boolean |
isBooleanType(javax.lang.model.type.TypeMirror type)
Checks if the type represents a boolean type, that is either boolean (primitive type) or
java.lang.Boolean.
|
static boolean |
isBoxedPrimitive(javax.lang.model.type.TypeMirror type) |
static boolean |
isBoxOf(javax.lang.model.type.TypeMirror declaredType,
javax.lang.model.type.TypeMirror primitiveType)
Returns true if declaredType is a Class that is used to box primitive type (e.g.
|
static boolean |
isClass(javax.lang.model.type.TypeMirror type)
Checks if the type represents a java.lang.Class declared type.
|
static boolean |
isDeclaredOfName(javax.lang.model.type.TypeMirror type,
java.lang.CharSequence qualifiedName)
Check if the type represents a declared type of the given qualified name.
|
static boolean |
isErasedSubtype(javax.lang.model.util.Types types,
javax.lang.model.type.TypeMirror subtype,
javax.lang.model.type.TypeMirror supertype)
Returns true if the erased type of subtype is a subtype of the erased type of supertype.
|
static boolean |
isFloating(javax.lang.model.type.TypeMirror type)
Returns true iff the argument is a floating point type.
|
static boolean |
isIntegral(javax.lang.model.type.TypeMirror type)
Returns true iff the argument is an integral type.
|
static boolean |
isNumeric(javax.lang.model.type.TypeMirror type)
Returns true iff the argument is a primitive numeric type.
|
static boolean |
isObject(javax.lang.model.type.TypeMirror type)
Checks if the type represents a java.lang.Object declared type.
|
static boolean |
isPrimitive(javax.lang.model.type.TypeMirror type)
Returns true iff the argument is a primitive type.
|
static boolean |
isString(javax.lang.model.type.TypeMirror type)
Checks if the type represents a java.lang.String declared type.
|
static boolean |
isThrowable(javax.lang.model.type.TypeMirror type) |
static javax.lang.model.type.TypeMirror |
typeFromClass(javax.lang.model.util.Types types,
javax.lang.model.util.Elements elements,
java.lang.Class<?> clazz)
Returns the
TypeMirror for a given Class . |
static javax.lang.model.type.TypeMirror |
upperBound(javax.lang.model.type.TypeMirror type)
If the argument is a bounded TypeVariable or WildcardType, return its non-variable,
non-wildcard upper bound.
|
static javax.lang.model.type.TypeKind |
widenedNumericType(javax.lang.model.type.TypeMirror left,
javax.lang.model.type.TypeMirror right)
Returns the widened numeric type for an arithmetic operation performed on a value of the left
type and the right type.
|
static javax.lang.model.element.TypeParameterElement |
wildcardToTypeParam(com.sun.tools.javac.code.Type.WildcardType wildcard)
Get the type parameter for this wildcard from the underlying type's bound field This field is
sometimes null, in that case this method will return null
|
static com.sun.tools.javac.code.Type |
wildLowerBound(javax.annotation.processing.ProcessingEnvironment env,
javax.lang.model.type.TypeMirror tm)
Version of com.sun.tools.javac.code.Types.wildLowerBound(Type) that works with both jdk8
(called upperBound there) and jdk8u.
|
static com.sun.tools.javac.code.Type |
wildUpperBound(javax.annotation.processing.ProcessingEnvironment env,
javax.lang.model.type.TypeMirror tm)
Version of com.sun.tools.javac.code.Types.wildUpperBound(Type) that works with both jdk8
(called upperBound there) and jdk8u.
|
public static javax.lang.model.element.Name getQualifiedName(javax.lang.model.type.DeclaredType type)
type
- the declared typepublic static boolean isObject(javax.lang.model.type.TypeMirror type)
type
- the typepublic static boolean isClass(javax.lang.model.type.TypeMirror type)
type
- the typepublic static boolean isString(javax.lang.model.type.TypeMirror type)
type
- the typepublic static boolean isBooleanType(javax.lang.model.type.TypeMirror type)
type
- the type to testpublic static boolean isDeclaredOfName(javax.lang.model.type.TypeMirror type, java.lang.CharSequence qualifiedName)
type
- the typepublic static boolean isBoxedPrimitive(javax.lang.model.type.TypeMirror type)
public static boolean isThrowable(javax.lang.model.type.TypeMirror type)
public static boolean isAnonymous(javax.lang.model.type.TypeMirror type)
public static boolean isPrimitive(javax.lang.model.type.TypeMirror type)
public static boolean areSamePrimitiveTypes(javax.lang.model.type.TypeMirror left, javax.lang.model.type.TypeMirror right)
public static boolean isNumeric(javax.lang.model.type.TypeMirror type)
public static boolean isIntegral(javax.lang.model.type.TypeMirror type)
public static boolean isFloating(javax.lang.model.type.TypeMirror type)
public static javax.lang.model.type.TypeKind widenedNumericType(javax.lang.model.type.TypeMirror left, javax.lang.model.type.TypeMirror right)
TypeKind
because creating
a TypeMirror
requires a Types
object from the ProcessingEnvironment
.public static javax.lang.model.type.TypeMirror upperBound(javax.lang.model.type.TypeMirror type)
type
- a typepublic static javax.lang.model.element.TypeParameterElement wildcardToTypeParam(com.sun.tools.javac.code.Type.WildcardType wildcard)
public static com.sun.tools.javac.code.Type wildUpperBound(javax.annotation.processing.ProcessingEnvironment env, javax.lang.model.type.TypeMirror tm)
public static com.sun.tools.javac.code.Type wildLowerBound(javax.annotation.processing.ProcessingEnvironment env, javax.lang.model.type.TypeMirror tm)
public static javax.lang.model.type.TypeMirror typeFromClass(javax.lang.model.util.Types types, javax.lang.model.util.Elements elements, java.lang.Class<?> clazz)
TypeMirror
for a given Class
.public static javax.lang.model.type.ArrayType createArrayType(javax.lang.model.util.Types types, javax.lang.model.type.TypeMirror componentType)
ArrayType
with elements of type componentType
.public static boolean isBoxOf(javax.lang.model.type.TypeMirror declaredType, javax.lang.model.type.TypeMirror primitiveType)
public static javax.lang.model.type.TypeMirror findConcreteUpperBound(javax.lang.model.type.TypeMirror boundedType)
public static boolean isErasedSubtype(javax.lang.model.util.Types types, javax.lang.model.type.TypeMirror subtype, javax.lang.model.type.TypeMirror supertype)
types
- a Types objectsubtype
- possible subtypesupertype
- possible supertype