Class Key (2.21.3)

public final class Key extends IncompleteKey

A key that is guaranteed to be complete and could be used to reference a Google Cloud Datastore Entity. This class is immutable. See Also: Google Cloud Datastore Entities, Properties, and Keys

Inheritance

Object > BaseKey > IncompleteKey > Key

Static Methods

fromUrlSafe(String urlSafe)

public static Key fromUrlSafe(String urlSafe)

Create a Key given its URL safe encoded form.

Parameter
Name Description
urlSafe String
Returns
Type Description
Key

newBuilder(IncompleteKey copyFrom, String name)

public static Key.Builder newBuilder(IncompleteKey copyFrom, String name)
Parameters
Name Description
copyFrom IncompleteKey
name String
Returns
Type Description
Key.Builder

newBuilder(IncompleteKey copyFrom, long id)

public static Key.Builder newBuilder(IncompleteKey copyFrom, long id)
Parameters
Name Description
copyFrom IncompleteKey
id long
Returns
Type Description
Key.Builder

newBuilder(Key copyFrom)

public static Key.Builder newBuilder(Key copyFrom)
Parameter
Name Description
copyFrom Key
Returns
Type Description
Key.Builder

newBuilder(Key parent, String kind, String name)

public static Key.Builder newBuilder(Key parent, String kind, String name)
Parameters
Name Description
parent Key
kind String
name String
Returns
Type Description
Key.Builder

newBuilder(Key parent, String kind, long id)

public static Key.Builder newBuilder(Key parent, String kind, long id)
Parameters
Name Description
parent Key
kind String
id long
Returns
Type Description
Key.Builder

newBuilder(String projectId, String kind, String name)

public static Key.Builder newBuilder(String projectId, String kind, String name)
Parameters
Name Description
projectId String
kind String
name String
Returns
Type Description
Key.Builder

newBuilder(String projectId, String kind, String name, String databaseId)

public static Key.Builder newBuilder(String projectId, String kind, String name, String databaseId)
Parameters
Name Description
projectId String
kind String
name String
databaseId String
Returns
Type Description
Key.Builder

newBuilder(String projectId, String kind, long id)

public static Key.Builder newBuilder(String projectId, String kind, long id)
Parameters
Name Description
projectId String
kind String
id long
Returns
Type Description
Key.Builder

newBuilder(String projectId, String kind, long id, String databaseId)

public static Key.Builder newBuilder(String projectId, String kind, long id, String databaseId)
Parameters
Name Description
projectId String
kind String
id long
databaseId String
Returns
Type Description
Key.Builder

Methods

getId()

public Long getId()

Returns the key's id or null if it has a name instead.

Returns
Type Description
Long

getName()

public String getName()

Returns the key's name or null if it has an id instead.

Returns
Type Description
String

getNameOrId()

public Object getNameOrId()

Returns the key's ID (as Long) or name (as String). Never null.

Returns
Type Description
Object

hasId()

public boolean hasId()
Returns
Type Description
boolean

hasName()

public boolean hasName()
Returns
Type Description
boolean

toUrlSafe()

public String toUrlSafe()

Returns the key in an encoded form that can be used as part of a URL.

Returns
Type Description
String