Package com.google.cloud.spanner
Class Type
java.lang.Object
com.google.cloud.spanner.Type
- All Implemented Interfaces:
Serializable
Describes a type in the Cloud Spanner type system. Types can either be primitive (for example,
INT64
and STRING
) or composite (for example, ARRAY<INT64>
or
STRUCT<INT64,STRING>
).
Type
instances are immutable.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumerates the categories of types.static final class
Describes an individual field in aSTRUCT type
. -
Method Summary
Modifier and TypeMethodDescriptionstatic Type
Returns a descriptor for an array ofelementType
.static Type
bool()
Returns the descriptor for theBOOL type
.static Type
bytes()
Returns the descriptor for theBYTES
type: a variable-length byte string.static Type
date()
Returns the descriptor for theDATE
type: a timezone independent date in the range [0001-01-01, 9999-12-31).boolean
static Type
float64()
Returns the descriptor for theFLOAT64
type: a floating point type with the same value domain as a Java {code double}.Returns the type descriptor for elements of thisARRAY
type.getCode()
Returns the type code corresponding to this type.int
getFieldIndex
(String fieldName) Returns the index of the field namedfieldName
in thisSTRUCT
type.Returns the fields of thisSTRUCT
type.int
hashCode()
static Type
int64()
Returns the descriptor for theINT64
type: an integral type with the same value domain as a Javalong
.static Type
json()
Returns the descriptor for theJSON
type.static Type
numeric()
Returns the descriptor for theNUMERIC
type.static Type
pgJsonb()
Returns the descriptor for theJSONB
type.static Type
Returns the descriptor for theNUMERIC
type with thePG_NUMERIC
type annotation.static Type
string()
Returns the descriptor for theSTRING
type: a variable-length Unicode character string.static Type
struct
(Type.StructField... fields) Returns a descriptor for aSTRUCT
type: an ordered collection of named and typed fields.static Type
struct
(Iterable<Type.StructField> fields) Returns a descriptor for aSTRUCT
type: an ordered collection of named and typed fields.static Type
Returns the descriptor for theTIMESTAMP
type: a nano precision timestamp in the range [0000-01-01 00:00:00, 9999-12-31 23:59:59.999999999 UTC].toString()
-
Method Details
-
bool
Returns the descriptor for theBOOL type
. -
int64
Returns the descriptor for theINT64
type: an integral type with the same value domain as a Javalong
. -
float64
Returns the descriptor for theFLOAT64
type: a floating point type with the same value domain as a Java {code double}. -
numeric
Returns the descriptor for theNUMERIC
type. -
pgNumeric
Returns the descriptor for theNUMERIC
type with thePG_NUMERIC
type annotation. -
string
Returns the descriptor for theSTRING
type: a variable-length Unicode character string. -
json
Returns the descriptor for theJSON
type. -
pgJsonb
Returns the descriptor for theJSONB
type. -
bytes
Returns the descriptor for theBYTES
type: a variable-length byte string. -
timestamp
Returns the descriptor for theTIMESTAMP
type: a nano precision timestamp in the range [0000-01-01 00:00:00, 9999-12-31 23:59:59.999999999 UTC]. -
date
Returns the descriptor for theDATE
type: a timezone independent date in the range [0001-01-01, 9999-12-31). -
array
Returns a descriptor for an array ofelementType
. -
struct
Returns a descriptor for aSTRUCT
type: an ordered collection of named and typed fields. -
struct
Returns a descriptor for aSTRUCT
type: an ordered collection of named and typed fields. -
getCode
Returns the type code corresponding to this type. -
getArrayElementType
Returns the type descriptor for elements of thisARRAY
type.- Throws:
IllegalStateException
- ifcode() != Code.ARRAY
-
getStructFields
Returns the fields of thisSTRUCT
type.- Returns:
- an immutable list of the fields
- Throws:
IllegalStateException
- ifcode() != Code.STRUCT
-
getFieldIndex
Returns the index of the field namedfieldName
in thisSTRUCT
type.- Throws:
IllegalArgumentException
- if there is not exactly one element ofgetStructFields()
withType.StructField.getName()
equal tofieldName
IllegalStateException
- ifcode() != Code.STRUCT
-
toString
-
equals
-
hashCode
public int hashCode()
-