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 Typefloat32()Returns the descriptor for theFLOAT32type: a floating point type with the same value domain as a Javafloat.static Typefloat64()Returns the descriptor for theFLOAT64type: a floating point type with the same value domain as a Javadouble.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 full package name for elements of thisProto or @code Enumtype.getSpannerTypeName(Dialect dialect) Returns the type name as used by the database in the given dialect.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 Typeinterval()Returns the descriptor for theINTERVALtype: an interval which represents a time duration as a tuple of 3 values (months, days, nanoseconds).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 TypepgOid()Returns the descriptor for thePG_OIDtype.static TypeTo get the descriptor for thePROTOtype.static TypeTo get the descriptor for theENUMtype.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()static Typeuuid()Returns the descriptor for theUUIDtype.
-
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. -
float32
Returns the descriptor for theFLOAT32type: a floating point type with the same value domain as a Javafloat. -
float64
Returns the descriptor for theFLOAT64type: a floating point type with the same value domain as a Javadouble. -
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. -
pgOid
Returns the descriptor for thePG_OIDtype. -
proto
To get the descriptor for thePROTOtype.- Parameters:
protoTypeFqn- Proto fully qualified name (ex: "examples.spanner.music.SingerInfo").
-
protoEnum
To get the descriptor for theENUMtype.- Parameters:
protoTypeFqn- Proto ENUM fully qualified name (ex: "examples.spanner.music.Genre")
-
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). -
uuid
Returns the descriptor for theUUIDtype. -
interval
Returns the descriptor for theINTERVALtype: an interval which represents a time duration as a tuple of 3 values (months, days, nanoseconds). [Interval(months:-120000, days: -3660000, nanoseconds: -316224000000000000000), Interval(months:120000, days: 3660000, nanoseconds: 316224000000000000000)]. -
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
-
getProtoTypeFqn
Returns the full package name for elements of thisProto or @code Enumtype.- Throws:
IllegalStateException- ifcode() != Code.PROTO or code() != Code.ENUM
-
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
-
getSpannerTypeName
Returns the type name as used by the database in the given dialect. -
equals
-
hashCode
public int hashCode()
-