@Immutable public final class Type extends Object implements Serializable
INT64
and STRING
) or composite (for example, ARRAY<INT64>
or STRUCT<INT64,STRING>
).
Type
instances are immutable.
Modifier and Type | Class and Description |
---|---|
static class |
Type.Code
Enumerates the categories of types.
|
static class |
Type.StructField
Describes an individual field in a
STRUCT type . |
Modifier and Type | Method and Description |
---|---|
static Type |
array(Type elementType)
Returns a descriptor for an array of
elementType . |
static Type |
bool()
Returns the descriptor for the
BOOL type . |
static Type |
bytes()
Returns the descriptor for the
BYTES type: a variable-length byte string. |
static Type |
date()
Returns the descriptor for the
DATE type: a timezone independent date in the range
[0001-01-01, 9999-12-31). |
boolean |
equals(Object o) |
static Type |
float64()
Returns the descriptor for the
FLOAT64 type: a floating point type with the same value
domain as a Java {code double}. |
Type |
getArrayElementType()
Returns the type descriptor for elements of this
ARRAY type. |
Type.Code |
getCode()
Returns the type code corresponding to this type.
|
int |
getFieldIndex(String fieldName)
Returns the index of the field named
fieldName in this STRUCT type. |
List<Type.StructField> |
getStructFields()
Returns the fields of this
STRUCT type. |
int |
hashCode() |
static Type |
int64()
Returns the descriptor for the
INT64 type: an integral type with the same value domain
as a Java long . |
static Type |
json()
Returns the descriptor for the
JSON type. |
static Type |
numeric()
Returns the descriptor for the
NUMERIC type. |
static Type |
pgNumeric()
Returns the descriptor for the
NUMERIC type with the PG_NUMERIC type
annotation. |
static Type |
string()
Returns the descriptor for the
STRING type: a variable-length Unicode character string. |
static Type |
struct(Iterable<Type.StructField> fields)
Returns a descriptor for a
STRUCT type: an ordered collection of named and typed
fields. |
static Type |
struct(Type.StructField... fields)
Returns a descriptor for a
STRUCT type: an ordered collection of named and typed
fields. |
static Type |
timestamp()
Returns the descriptor for the
TIMESTAMP type: a nano precision timestamp in the range
[0000-01-01 00:00:00, 9999-12-31 23:59:59.999999999 UTC]. |
String |
toString() |
public static Type bool()
BOOL type
.public static Type int64()
INT64
type: an integral type with the same value domain
as a Java long
.public static Type float64()
FLOAT64
type: a floating point type with the same value
domain as a Java {code double}.public static Type numeric()
NUMERIC
type.public static Type pgNumeric()
NUMERIC
type with the PG_NUMERIC
type
annotation.public static Type string()
STRING
type: a variable-length Unicode character string.public static Type json()
JSON
type.public static Type bytes()
BYTES
type: a variable-length byte string.public static Type timestamp()
TIMESTAMP
type: a nano precision timestamp in the range
[0000-01-01 00:00:00, 9999-12-31 23:59:59.999999999 UTC].public static Type date()
DATE
type: a timezone independent date in the range
[0001-01-01, 9999-12-31).public static Type struct(Iterable<Type.StructField> fields)
STRUCT
type: an ordered collection of named and typed
fields.public static Type struct(Type.StructField... fields)
STRUCT
type: an ordered collection of named and typed
fields.public Type.Code getCode()
public Type getArrayElementType()
ARRAY
type.IllegalStateException
- if code() != Code.ARRAY
public List<Type.StructField> getStructFields()
STRUCT
type.IllegalStateException
- if code() != Code.STRUCT
public int getFieldIndex(String fieldName)
fieldName
in this STRUCT
type.IllegalArgumentException
- if there is not exactly one element of getStructFields()
with Type.StructField.getName()
equal to fieldName
IllegalStateException
- if code() != Code.STRUCT
Copyright © 2022 Google LLC. All rights reserved.