Package org.apache.calcite.linq4j.tree
Class Types
- java.lang.Object
-
- org.apache.calcite.linq4j.tree.Types
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTypes.ArrayTypeArray type.static classTypes.MapTypeMap type.(package private) static classTypes.ParameterizedTypeImplImplementation ofParameterizedType.static interfaceTypes.RecordFieldField that belongs to a record.static interfaceTypes.RecordTypeBase class for record-like types that do not mapped to (currently loaded) JavaClassobjects.
-
Constructor Summary
Constructors Modifier Constructor Description privateTypes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static booleanallAssignable(boolean varArgs, Class[] parameterTypes, Class[] argumentTypes)(package private) static ClassarrayClass(Type type)(package private) static TypearrayType(Type type)(package private) static TypearrayType(Type type, int dimension)private static booleanassignableFrom(Class parameter, Class argument)Returns whether a parameter is assignable from an argument by virtue of (a) sub-classing (e.g.static Typebox(Type type)(package private) static StringboxClassName(Type type)Boxes a type, if it is primitive, and returns the type name.static 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.(package private) static StringclassName(Type type)static voiddiscard(Object o)static PseudoFieldfield(Field field)(package private) static Typegcd(Type... types)Returns the most restrictive type that is assignable from all given types.static TypegetComponentType(Type type)Returns the component type of an array.(package private) static TypegetComponentTypeN(Type type)static TypegetElementType(Type type)Returns the element type of aCollection,Iterable(includingQueryableandEnumerable),Iterator,Enumerator, or an array.(package private) static FieldgetField(String fieldName, Class clazz)(package private) static PseudoFieldgetField(String fieldName, Type type)private static Types.RecordFieldgetRecordField(String fieldName, Types.RecordType type)private static Types.RecordFieldgetSystemField(String fieldName, Class clazz)static booleanisArray(Type type)static booleanisAssignableFrom(Type type0, Type type)static ConstructorlookupConstructor(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 FieldnthField(int ordinal, Class clazz)static PseudoFieldnthField(int ordinal, Type clazz)static Typeof(Type type, Type... typeArguments)Creates a type with generic parameters.static TypestripGenerics(Type type)static ClasstoClass(Type type)(package private) static Class[]toClassArray(Iterable<? extends Expression> arguments)(package private) static Class[]toClassArray(Collection<Type> types)private static <T> List<T>toList(T[] ts)Returns a list backed by a copy of an array.static Typeunbox(Type type)
-
-
-
Method Detail
-
getElementType
public static Type getElementType(Type type)
Returns the element type of aCollection,Iterable(includingQueryableandEnumerable),Iterator,Enumerator, or an array.Returns null if the type is not one of these.
-
toList
private static <T> List<T> toList(T[] ts)
Returns a list backed by a copy of an array. The contents of the list will not change even if the contents of the array are subsequently modified.
-
getField
static PseudoField getField(String fieldName, Type type)
-
getRecordField
private static Types.RecordField getRecordField(String fieldName, Types.RecordType type)
-
getSystemField
private static Types.RecordField getSystemField(String fieldName, Class clazz)
-
toClassArray
static Class[] toClassArray(Collection<Type> types)
-
toClassArray
static Class[] toClassArray(Iterable<? extends Expression> arguments)
-
getComponentType
public static Type getComponentType(Type type)
Returns the component type of an array.
-
boxClassName
static String boxClassName(Type type)
Boxes a type, if it is primitive, and returns the type name. The type is abbreviated if it is in the "java.lang" package.For example, boxClassName(int) returns "Integer"; boxClassName(List<String>) returns "List<String>"
- Parameters:
type- Type- Returns:
- Class name
-
isArray
public static boolean isArray(Type type)
-
nthField
public static PseudoField nthField(int ordinal, Type clazz)
-
allAssignable
static boolean allAssignable(boolean varArgs, Class[] parameterTypes, Class[] argumentTypes)
-
assignableFrom
private static boolean assignableFrom(Class parameter, Class argument)
Returns whether a parameter is assignable from an argument by virtue of (a) sub-classing (e.g. Writer is assignable from PrintWriter) and (b) up-casting (e.g. int is assignable from short).- Parameters:
parameter- Parameter typeargument- Argument type- Returns:
- Whether parameter can be assigned from argument
-
lookupMethod
public static Method lookupMethod(Class clazz, String methodName, Class... argumentTypes)
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
public static Constructor lookupConstructor(Type type, Class... argumentTypes)
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
-
discard
public static void discard(Object o)
-
gcd
static Type gcd(Type... types)
Returns the most restrictive type that is assignable from all given types.
-
castIfNecessary
public 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.- Parameters:
returnType- Desired typeexpression- Expression- Returns:
- Expression of desired type
-
field
public static PseudoField field(Field field)
-
-