public final class Key extends IncompleteKey
Entity
. This class is immutable.Modifier and Type | Class and Description |
---|---|
static class |
Key.Builder |
Modifier and Type | Method and Description |
---|---|
static Key |
fromUrlSafe(String urlSafe)
Create a
Key given its URL safe encoded form. |
Long |
getId()
Returns the key's id or
null if it has a name instead. |
String |
getName()
Returns the key's name or
null if it has an id instead. |
Object |
getNameOrId()
|
boolean |
hasId() |
boolean |
hasName() |
static Key.Builder |
newBuilder(IncompleteKey copyFrom,
long id) |
static Key.Builder |
newBuilder(IncompleteKey copyFrom,
String name) |
static Key.Builder |
newBuilder(Key copyFrom) |
static Key.Builder |
newBuilder(Key parent,
String kind,
long id) |
static Key.Builder |
newBuilder(Key parent,
String kind,
String name) |
static Key.Builder |
newBuilder(String projectId,
String kind,
long id) |
static Key.Builder |
newBuilder(String projectId,
String kind,
long id,
String databaseId) |
static Key.Builder |
newBuilder(String projectId,
String kind,
String name) |
static Key.Builder |
newBuilder(String projectId,
String kind,
String name,
String databaseId) |
String |
toUrlSafe()
Returns the key in an encoded form that can be used as part of a URL.
|
getParent, newBuilder, newBuilder, newBuilder, newBuilderWithDatabaseId
equals, getAncestors, getDatabaseId, getKind, getNamespace, getProjectId, hashCode, toString
public boolean hasId()
public Long getId()
null
if it has a name instead.public boolean hasName()
public String getName()
null
if it has an id instead.public Object getNameOrId()
public String toUrlSafe()
public static Key fromUrlSafe(String urlSafe)
Key
given its URL safe encoded form.IllegalArgumentException
- when decoding failspublic static Key.Builder newBuilder(String projectId, String kind, String name)
@BetaApi public static Key.Builder newBuilder(String projectId, String kind, String name, String databaseId)
public static Key.Builder newBuilder(String projectId, String kind, long id)
@BetaApi public static Key.Builder newBuilder(String projectId, String kind, long id, String databaseId)
public static Key.Builder newBuilder(Key copyFrom)
public static Key.Builder newBuilder(IncompleteKey copyFrom, String name)
public static Key.Builder newBuilder(IncompleteKey copyFrom, long id)
public static Key.Builder newBuilder(Key parent, String kind, String name)
public static Key.Builder newBuilder(Key parent, String kind, long id)
Copyright © 2023 Google LLC. All rights reserved.