| Modifier and Type | Class and Description |
|---|---|
static class |
Types.ArrayType
Array type.
|
static class |
Types.MapType
Map type.
|
static interface |
Types.RecordField
Field that belongs to a record.
|
static interface |
Types.RecordType
Base class for record-like types that do not mapped to (currently
loaded) Java
Class objects. |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
allAssignable(boolean varArgs,
Class[] parameterTypes,
Class[] argumentTypes) |
static Type |
box(Type type) |
static Expression |
castIfNecessary(Type returnType,
Expression expression)
Wraps an expression in a cast if it is not already of the desired type,
or cannot be implicitly converted to it.
|
static void |
discard(Object o) |
static PseudoField |
field(Field field) |
static @Nullable Type |
getComponentType(Type type)
Returns the component type of an array.
|
static @Nullable Type |
getElementType(Type type)
Returns the element type of a
Collection, Iterable
(including Queryable and
Enumerable), Iterator,
Enumerator, or an array. |
static boolean |
isArray(Type type) |
static boolean |
isAssignableFrom(Type type0,
Type type) |
static Constructor |
lookupConstructor(Type type,
Class... argumentTypes)
Finds a constructor of a given class that accepts a given set of
arguments.
|
static Field |
lookupField(Type type,
String name) |
static Method |
lookupMethod(Class clazz,
String methodName,
Class... argumentTypes)
Finds a method of a given name that accepts a given set of arguments.
|
static boolean |
needTypeCast(Type fromType,
Type toType)
When trying to cast/convert a
Type to another Type,
it is necessary to pre-check whether the cast operation is needed. |
static Field |
nthField(int ordinal,
Class clazz) |
static PseudoField |
nthField(int ordinal,
Type clazz) |
static Type |
of(Type type,
Type... typeArguments)
Creates a type with generic parameters.
|
static Type |
stripGenerics(Type type) |
static Class |
toClass(Type type) |
static Class[] |
toClassArray(Iterable<? extends Expression> arguments) |
static Type |
unbox(Type type) |
public static @Nullable Type getElementType(Type type)
Collection, Iterable
(including Queryable and
Enumerable), Iterator,
Enumerator, or an array.
Returns null if the type is not one of these.
public static Class[] toClassArray(Iterable<? extends Expression> arguments)
public static @Nullable Type getComponentType(Type type)
public static boolean isArray(Type type)
public static PseudoField nthField(int ordinal, Type clazz)
public static boolean allAssignable(boolean varArgs,
Class[] parameterTypes,
Class[] argumentTypes)
public static Method lookupMethod(Class clazz, String methodName, Class... argumentTypes)
clazz - Class against which method is invokedmethodName - Name of methodargumentTypes - Types of argumentsRuntimeException - if method not foundpublic static Constructor lookupConstructor(Type type, Class... argumentTypes)
type - Class against which method is invokedargumentTypes - Types of argumentsRuntimeException - if method not foundpublic static void discard(Object o)
public static Expression castIfNecessary(Type returnType, Expression expression)
returnType - Desired typeexpression - Expressionpublic static boolean needTypeCast(Type fromType, Type toType)
Type to another Type,
it is necessary to pre-check whether the cast operation is needed.
We summarize general exceptions, including:
toType equals with original Type fromTypeRecordType,
since the mapping Java Class might not generated yetfromType - original typetoType - target typepublic static PseudoField field(Field field)
Copyright © 2012-2021 Apache Software Foundation. All Rights Reserved.