Interface DataType
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
ArrayType, BooleanType, ByteType, CharType, DateTimeType, DateType, DecimalType, DoubleType, FloatType, IntType, LongType, ObjectType, PrimitiveType, ShortType, StringType, StructType, TimeType
The interface of data types.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic DataTypeReturns the common type.id()Returns the type ID enum.static DataTypeInfers the type of string.default booleanReturns true if the type is boolean or Boolean.default booleanisByte()Returns true if the type is byte or Byte.default booleanisChar()Returns true if the type is char or Char.default booleanReturns true if the type is decimal.default booleanisDouble()Returns true if the type is double or Double.default booleanisFloat()Returns true if the type is float or Float.default booleanReturns true if the type is float or double.default booleanisInt()Returns true if the type is int or Integer.default booleanReturns true if the type is int, long, short or byte.default booleanisLong()Returns true if the type is long or Long.default booleanReturns true if the data may be null.default booleanReturns true if the type is numeric (integral or floating).default booleanisObject()Returns true if the type is ObjectType.default booleanReturns true if this is a primitive data type.default booleanisShort()Returns true if the type is short or Short.default booleanisString()Returns true if the type is String.name()Returns the type name used in external catalogs.static DataTypeReturns the DataType of a class.static DataTypeReturns a DataType from its string representation.static DataTypeReturns the DataType of a JDBC type.static DataTypeType promotion when apply to expressions.default StringReturns the string representation of a value of the type.Returns the value from its string representation.
-
Method Details
-
id
-
name
String name()Returns the type name used in external catalogs. DataType.of(name()) should return the same type.- Returns:
- the type name used in external catalogs.
-
valueOf
-
toString
-
isNullable
default boolean isNullable()Returns true if the data may be null.- Returns:
- true if the data may be null.
-
isPrimitive
default boolean isPrimitive()Returns true if this is a primitive data type.- Returns:
- true if this is a primitive data type.
-
isFloating
default boolean isFloating()Returns true if the type is float or double.- Returns:
- true if the type is float or double.
-
isIntegral
default boolean isIntegral()Returns true if the type is int, long, short or byte.- Returns:
- true if the type is int, long, short or byte.
-
isNumeric
default boolean isNumeric()Returns true if the type is numeric (integral or floating).- Returns:
- true if the type is numeric (integral or floating).
-
isBoolean
default boolean isBoolean()Returns true if the type is boolean or Boolean.- Returns:
- true if the type is boolean or Boolean.
-
isChar
default boolean isChar()Returns true if the type is char or Char.- Returns:
- true if the type is char or Char.
-
isByte
default boolean isByte()Returns true if the type is byte or Byte.- Returns:
- true if the type is byte or Byte.
-
isShort
default boolean isShort()Returns true if the type is short or Short.- Returns:
- true if the type is short or Short.
-
isInt
default boolean isInt()Returns true if the type is int or Integer.- Returns:
- true if the type is int or Integer.
-
isLong
default boolean isLong()Returns true if the type is long or Long.- Returns:
- true if the type is long or Long.
-
isDecimal
default boolean isDecimal()Returns true if the type is decimal.- Returns:
- true if the type is decimal.
-
isFloat
default boolean isFloat()Returns true if the type is float or Float.- Returns:
- true if the type is float or Float.
-
isDouble
default boolean isDouble()Returns true if the type is double or Double.- Returns:
- true if the type is double or Double.
-
isString
default boolean isString()Returns true if the type is String.- Returns:
- true if the type is String.
-
isObject
default boolean isObject()Returns true if the type is ObjectType.- Returns:
- true if the type is ObjectType.
-
prompt
Type promotion when apply to expressions. First, all byte, short, and char values are promoted to int. Then, if one operand is a long, the whole expression is promoted to long. If one operand is a float, the entire expression is promoted to float. If any of the operands is double, the result is double.- Parameters:
a- the data type.b- the data type.- Returns:
- the promoted type.
-
coerce
-
infer
-
of
Returns a DataType from its string representation.- Parameters:
s- the string representation of data type.- Returns:
- the data type.
- Throws:
ClassNotFoundException- when fails to load a class.
-
of
-
of
-