Package org.apache.calcite.linq4j.tree
Class Types
java.lang.Object
org.apache.calcite.linq4j.tree.Types
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classArray type.static classMap type.static interfaceField that belongs to a record.static interfaceBase class for record-like types that do not mapped to (currently loaded) JavaClassobjects. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanallAssignable(boolean varArgs, Class<?>[] parameterTypes, Class<?>[] argumentTypes) static Typestatic ExpressioncastIfNecessary(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 voidstatic PseudoFieldstatic @Nullable TypegetComponentType(Type type) Returns the component type of an array.static @Nullable TypegetElementType(Type type) Returns the element type of aCollection,Iterable(includingQueryableandEnumerable),Iterator,Enumerator, or an array.static booleanstatic booleanisAssignableFrom(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 FieldlookupField(Type type, String name) static MethodlookupMethod(Class<?> clazz, String methodName, Class<?>... argumentTypes) Finds a method of a given name that accepts a given set of arguments.static booleanneedTypeCast(Type fromType, Type toType) When trying to cast/convert aTypeto anotherType, it is necessary to pre-check whether the cast operation is needed.static Fieldstatic PseudoFieldstatic TypeCreates a type with generic parameters.static TypestripGenerics(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(includingQueryableandEnumerable),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 aTypeto anotherType, it is necessary to pre-check whether the cast operation is needed. We summarize general exceptions, including:- target Type
toTypeequals 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
-