Package com.google.cloud.spanner
Class Key
- java.lang.Object
-
- com.google.cloud.spanner.Key
-
- All Implemented Interfaces:
Serializable
public final class Key extends Object implements Serializable
Represents a row key in a Cloud Spanner table or index. A key is a tuple of values constrained to the scalar Cloud Spanner types: currently these areBOOLEAN
,INT64
,FLOAT64
,STRING
,BYTES
andTIMESTAMP
. Values may be null where the table definition permits it.Key
is used to define the row, or endpoints of a range of rows, to retrieve in read operations or to delete in a mutation.Key
instances are immutable.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Key.Builder
Builder forKey
instances.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Iterable<Object>
getParts()
Returns the parts in this key.int
hashCode()
static Key.Builder
newBuilder()
Returns a new builder for constructing a key.static Key
of(Object... values)
Construct a key with parts specified byvalues
.int
size()
Returns the number of parts in this key, includingnull
values.Key.Builder
toBuilder()
Returns a builder initialized with the value of this key.String
toString()
-
-
-
Method Detail
-
of
public static Key of(Object... values)
Construct a key with parts specified byvalues
. Each object invalues
must be eithernull
or one of the following supported types:Boolean
for theBOOL
Cloud Spanner typeInteger
,Long
for theINT64
Cloud Spanner typeFloat
,Double
for theFLOAT64
Cloud Spanner typeBigDecimal
for theNUMERIC
Cloud Spanner typeString
for theSTRING
Cloud Spanner typeString
for theJSON
Cloud Spanner typeByteArray
for theBYTES
Cloud Spanner typeTimestamp
for theTIMESTAMP
Cloud Spanner typeDate
for theDATE
Cloud Spanner type
- Throws:
IllegalArgumentException
- if any member ofvalues
is not a supported type
-
newBuilder
public static Key.Builder newBuilder()
Returns a new builder for constructing a key.
-
size
public int size()
Returns the number of parts in this key, includingnull
values.
-
getParts
public Iterable<Object> getParts()
Returns the parts in this key. Each part is represented by the corresponding Cloud Spanner type's canonical Java type, as listed below. Note that other types supported byof(Object...)
are converted to one of the canonical types.BOOL
is represented byBoolean
INT64
is represented byLong
FLOAT64
is represented byDouble
NUMERIC
is represented byBigDecimal
STRING
is represented byString
JSON
is represented byString
BYTES
is represented byByteArray
TIMESTAMP
is represented byTimestamp
DATE
is represented byDate
- Returns:
- an unmodifiable list containing the key parts
-
toBuilder
public Key.Builder toBuilder()
Returns a builder initialized with the value of this key.
-
-