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,BYTESandTIMESTAMP. Values may be null where the table definition permits it.Keyis used to define the row, or endpoints of a range of rows, to retrieve in read operations or to delete in a mutation.Keyinstances are immutable.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKey.BuilderBuilder forKeyinstances.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Iterable<Object>getParts()Returns the parts in this key.inthashCode()static Key.BuildernewBuilder()Returns a new builder for constructing a key.static Keyof(Object... values)Construct a key with parts specified byvalues.intsize()Returns the number of parts in this key, includingnullvalues.Key.BuildertoBuilder()Returns a builder initialized with the value of this key.StringtoString()
-
-
-
Method Detail
-
of
public static Key of(Object... values)
Construct a key with parts specified byvalues. Each object invaluesmust be eithernullor one of the following supported types:Booleanfor theBOOLCloud Spanner typeInteger,Longfor theINT64Cloud Spanner typeFloat,Doublefor theFLOAT64Cloud Spanner typeBigDecimalfor theNUMERICCloud Spanner typeStringfor theSTRINGCloud Spanner typeStringfor theJSONCloud Spanner typeByteArrayfor theBYTESCloud Spanner typeTimestampfor theTIMESTAMPCloud Spanner typeDatefor theDATECloud Spanner type
- Throws:
IllegalArgumentException- if any member ofvaluesis 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, includingnullvalues.
-
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.BOOLis represented byBooleanINT64is represented byLongFLOAT64is represented byDoubleNUMERICis represented byBigDecimalSTRINGis represented byStringJSONis represented byStringBYTESis represented byByteArrayTIMESTAMPis represented byTimestampDATEis 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.
-
-