Package org.apache.calcite.linq4j.tree
Class Types
java.lang.Object
org.apache.calcite.linq4j.tree.Types
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Array type.static class
Map type.static interface
Field that belongs to a record.static interface
Base class for record-like types that do not mapped to (currently loaded) JavaClass
objects. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
allAssignable
(boolean varArgs, Class<?>[] parameterTypes, Class<?>[] argumentTypes) static 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
static PseudoField
static @Nullable Type
getComponentType
(Type type) Returns the component type of an array.static @Nullable Type
getElementType
(Type type) Returns the element type of aCollection
,Iterable
(includingQueryable
andEnumerable
),Iterator
,Enumerator
, or an array.static boolean
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 aType
to anotherType
, it is necessary to pre-check whether the cast operation is needed.static Field
static PseudoField
static Type
Creates a type with generic parameters.static Type
stripGenerics
(Type type) static Class<?>
static Class<?>[]
toClassArray
(Iterable<? extends Expression> arguments) static Type
-
Method Details
-
of
Creates a type with generic parameters. -
getElementType
Returns the element type of aCollection
,Iterable
(includingQueryable
andEnumerable
),Iterator
,Enumerator
, or an array.Returns null if the type is not one of these.
-
toClass
-
toClassArray
-
getComponentType
Returns the component type of an array. -
box
-
unbox
-
isAssignableFrom
-
isArray
-
nthField
-
nthField
-
allAssignable
-
lookupMethod
Finds a method of a given name that accepts a given set of arguments. Includes in its search inherited methods and methods with wider argument types.- Parameters:
clazz
- Class against which method is invokedmethodName
- Name of methodargumentTypes
- Types of arguments- Returns:
- A method with the given name that matches the arguments given
- Throws:
RuntimeException
- if method not found
-
lookupConstructor
Finds a constructor of a given class that accepts a given set of arguments. Includes in its search methods with wider argument types.- Parameters:
type
- Class against which method is invokedargumentTypes
- Types of arguments- Returns:
- A method with the given name that matches the arguments given
- Throws:
RuntimeException
- if method not found
-
lookupField
-
discard
-
castIfNecessary
Wraps an expression in a cast if it is not already of the desired type, or cannot be implicitly converted to it.- Parameters:
returnType
- Desired typeexpression
- Expression- Returns:
- Expression of desired type
-
needTypeCast
When trying to cast/convert aType
to anotherType
, it is necessary to pre-check whether the cast operation is needed. We summarize general exceptions, including:- target Type
toType
equals with original TypefromType
- target Type can be assignable from original Type
- target Type is an instance of
RecordType
, since the mapping Java Class might not generated yet
- Parameters:
fromType
- original typetoType
- target type- Returns:
- Whether a cast operation is needed
- target Type
-
field
-
stripGenerics
-