public class Key<T> extends Object implements Serializable, Comparable<Key<?>>
A typesafe wrapper for the datastore Key object.
Modifier and Type | Field and Description |
---|---|
protected Key<?> |
parent
Cache the instance of the parent wrapper to avoid unnecessary garbage
|
protected com.google.cloud.datastore.Key |
raw |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Key<?> other)
The new cloud sdk Key doesn't have compareTo(), so we reimplement the logic from the old GAE SDK.
|
static <T> Key<T> |
create(Class<? extends T> kindClass,
long id)
Key.create(Blah.class, id) is easier to type than new Key
|
static <T> Key<T> |
create(Class<? extends T> kindClass,
String name)
Key.create(Blah.class, name) is easier to type than new Key
|
static <T> Key<T> |
create(com.google.cloud.datastore.Key raw)
Key.create(key) is easier to type than new Key
|
static <T> Key<T> |
create(Key<?> parent,
Class<? extends T> kindClass,
long id)
Key.create(parent, Blah.class, id) is easier to type than new Key
|
static <T> Key<T> |
create(Key<?> parent,
Class<? extends T> kindClass,
String name)
Key.create(parent, Blah.class, name) is easier to type than new Key
|
static <T> Key<T> |
create(String urlSafeString)
Key.create(urlSafeString) is easier to type than new Key
|
static <T> Key<T> |
create(T pojo)
Create a key from a registered POJO entity.
|
boolean |
equivalent(Key<T> other)
A type-safe equivalence comparison
|
boolean |
equivalent(Ref<T> other)
A type-safe equivalence comparison
|
long |
getId() |
String |
getKind() |
static String |
getKind(Class<?> clazz)
Determines the kind for a Class, as understood by the datastore.
|
String |
getName() |
<V> Key<V> |
getParent() |
com.google.cloud.datastore.Key |
getRaw() |
<V> Key<V> |
getRoot()
Gets the root of a parent graph of keys.
|
String |
getString()
Deprecated.
Use toUrlSafe() instead.
|
static <V> Key<V> |
key(com.google.cloud.datastore.Key raw)
Easy null-safe conversion of the raw key.
|
static com.google.cloud.datastore.Key |
key(Key<?> typed)
Easy null-safe conversion of the typed key.
|
String |
toLegacyUrlSafe()
Generates the string that would have been generated by the old appengine SDK.
|
String |
toString()
Creates a human-readable version of this key
|
String |
toUrlSafe()
Call toUrlSafe() on the underlying Key.
|
String |
toWebSafeString()
Deprecated.
Use toLegacyUrlSafe(), or if you aren't trying to generate old-style keys, use
toUrlSafe().
|
static <T> Key<T> |
valueOf(String webSafeString)
This is an alias for Key.create(String) which exists for JAX-RS compliance.
|
protected final com.google.cloud.datastore.Key raw
protected transient Key<?> parent
public static <T> Key<T> create(com.google.cloud.datastore.Key raw)
public static <T> Key<T> create(Class<? extends T> kindClass, long id)
public static <T> Key<T> create(Class<? extends T> kindClass, String name)
public static <T> Key<T> create(Key<?> parent, Class<? extends T> kindClass, long id)
public static <T> Key<T> create(Key<?> parent, Class<? extends T> kindClass, String name)
public static <T> Key<T> create(String urlSafeString)
public static <T> Key<T> valueOf(String webSafeString)
public static <T> Key<T> create(T pojo)
public com.google.cloud.datastore.Key getRaw()
public long getId()
public String getName()
public String getKind()
public <V> Key<V> getParent()
public <V> Key<V> getRoot()
public int compareTo(Key<?> other)
The new cloud sdk Key doesn't have compareTo(), so we reimplement the logic from the old GAE SDK.
compareTo
in interface Comparable<Key<?>>
public String toString()
@Deprecated public String getString()
@Deprecated public String toWebSafeString()
public String toUrlSafe()
Key<?>
using the
constructor that takes a string. Note that toString() is only useful for debugging;
it cannot be used to create a key with Key.create(String).public String toLegacyUrlSafe()
Key<?>
understands both formats.public static <V> Key<V> key(com.google.cloud.datastore.Key raw)
public static com.google.cloud.datastore.Key key(Key<?> typed)
Copyright © 2019. All rights reserved.