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
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerates the categories of types.static final classDescribes an individual field in aSTRUCT type. -
Method Summary
Modifier and TypeMethodDescriptionstatic TypeReturns a descriptor for an array ofelementType.static Typebool()Returns the descriptor for theBOOL type.static Typebytes()Returns the descriptor for theBYTEStype: a variable-length byte string.static Typedate()Returns the descriptor for theDATEtype: a timezone independent date in the range [0001-01-01, 9999-12-31).booleanstatic Typefloat64()Returns the descriptor for theFLOAT64type: a floating point type with the same value domain as a Java {code double}.Returns the type descriptor for elements of thisARRAYtype.getCode()Returns the type code corresponding to this type.intgetFieldIndex(String fieldName) Returns the index of the field namedfieldNamein thisSTRUCTtype.Returns the fields of thisSTRUCTtype.inthashCode()static Typeint64()Returns the descriptor for theINT64type: an integral type with the same value domain as a Javalong.static Typejson()Returns the descriptor for theJSONtype.static Typenumeric()Returns the descriptor for theNUMERICtype.static TypepgJsonb()Returns the descriptor for theJSONBtype.static TypeReturns the descriptor for theNUMERICtype with thePG_NUMERICtype annotation.static Typestring()Returns the descriptor for theSTRINGtype: a variable-length Unicode character string.static Typestruct(Type.StructField... fields) Returns a descriptor for aSTRUCTtype: an ordered collection of named and typed fields.static Typestruct(Iterable<Type.StructField> fields) Returns a descriptor for aSTRUCTtype: an ordered collection of named and typed fields.static TypeReturns the descriptor for theTIMESTAMPtype: 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 theINT64type: an integral type with the same value domain as a Javalong. -
float64
Returns the descriptor for theFLOAT64type: a floating point type with the same value domain as a Java {code double}. -
numeric
Returns the descriptor for theNUMERICtype. -
pgNumeric
Returns the descriptor for theNUMERICtype with thePG_NUMERICtype annotation. -
string
Returns the descriptor for theSTRINGtype: a variable-length Unicode character string. -
json
Returns the descriptor for theJSONtype. -
pgJsonb
Returns the descriptor for theJSONBtype. -
bytes
Returns the descriptor for theBYTEStype: a variable-length byte string. -
timestamp
Returns the descriptor for theTIMESTAMPtype: 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 theDATEtype: 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 aSTRUCTtype: an ordered collection of named and typed fields. -
struct
Returns a descriptor for aSTRUCTtype: 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 thisARRAYtype.- Throws:
IllegalStateException- ifcode() != Code.ARRAY
-
getStructFields
Returns the fields of thisSTRUCTtype.- Returns:
- an immutable list of the fields
- Throws:
IllegalStateException- ifcode() != Code.STRUCT
-
getFieldIndex
Returns the index of the field namedfieldNamein thisSTRUCTtype.- Throws:
IllegalArgumentException- if there is not exactly one element ofgetStructFields()withType.StructField.getName()equal tofieldNameIllegalStateException- ifcode() != Code.STRUCT
-
toString
-
equals
-
hashCode
public int hashCode()
-