Package com.googlecode.objectify.impl
Class Keys
java.lang.Object
com.googlecode.objectify.impl.Keys
Gives us a slightly more organized interface for manipulating keys. While this is part of Objectify's public interface, you probably shouldn't use it. It's subject to change without notice. If you want to work with keys, use the Key.create() methods.
- Author:
- Jeff Schnitzer invalid input: '<'[email protected]>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <B extends com.google.cloud.datastore.BaseKey.Builder<B>>
BadjustNamespace
(B builder, String namespace) Be sensitive to the thread local namespace, if setstatic com.google.cloud.datastore.KeyFactory
adjustNamespace
(com.google.cloud.datastore.KeyFactory keyFactory, String namespace) Be sensitive to the thread local namespace, if set<T> Key
<T> anythingToKey
(Object keyOrEntity, String namespaceHint) Gets the Keygiven an object that might be a Key, Key , or entity. com.google.cloud.datastore.Key
anythingToRawKey
(Object keyOrEntity, String namespaceHint) Gets the raw datstore Key given an object that might be a Key, Key, or entity. <T> Key
<T> namespace and parent are mutually exclusive<T> Key
<T> namespace and parent are mutually exclusive<T> Key
<T> createKeyAny
(String namespace, Key<?> parent, Class<T> kind, Object id) Construct a Keyinvalid input: '<'?> from a Long or String id namespace and parent are mutually exclusivecreateKeys
(String namespace, Key<?> parent, Class<T> kind, Iterable<?> ids) Make a list of Keyinvalid input: '<'?>scom.google.cloud.datastore.Key
namespace and parent are mutually exclusivecom.google.cloud.datastore.Key
namespace and parent are mutually exclusivecom.google.cloud.datastore.Key
createRawAny
(String namespace, com.google.cloud.datastore.Key parent, String kind, Object id) Construct a Key from a Long or String idcom.google.cloud.datastore.IncompleteKey
createRawIncomplete
(String namespace, com.google.cloud.datastore.Key parent, String kind) namespace and parent are mutually exclusivestatic com.google.cloud.datastore.Key
fromUrlSafe
(String urlSafeKey) Understands both the legacy format "ag1zfnZvb2Rvb2R5bmUwcgcLEgFCGAEM" and new format, providing the key either way.static <S> com.google.cloud.datastore.Value
<S> getIdValue
(com.google.cloud.datastore.IncompleteKey key) Gets the String or Long id from the key as a Value, or null if incompletestatic com.google.cloud.datastore.Key
getKey
(com.google.cloud.datastore.FullEntity<?> entity) <T> KeyMetadata
<T> getMetadata
(Key<T> key) <T> KeyMetadata
<T> getMetadataSafe
(Class<T> clazz) <T> KeyMetadata
<T> getMetadataSafe
(T pojo) <T> Key
<T> static com.google.cloud.datastore.Key
Null-safe extraction of the raw keycom.google.cloud.datastore.Key
boolean
requiresAutogeneratedId
(Object entity) static com.google.cloud.datastore.Key[]
toArray
(Collection<com.google.cloud.datastore.Key> collection)
-
Constructor Details
-
Keys
public Keys()
-
-
Method Details
-
keyOf
- Returns:
- the Keyinvalid input: '<'?> for a registered pojo entity.
-
rawKeyOf
- Returns:
- the native datastore key for a registered pojo entity (or FullEntity).
-
getMetadataSafe
- Returns:
- the metadata for a registered pojo, or throw exception if none
- Throws:
IllegalStateException
- if the pojo class has not been registered
-
getMetadataSafe
- Returns:
- the metadata for a registeerd pojo, or throw exception if none
- Throws:
IllegalStateException
- if the pojo class has not been registered
-
getMetadata
- Returns:
- the metadata for a registered pojo, or null if there is none
-
anythingToKey
Gets the Key
given an object that might be a Key, Key , or entity. - Parameters:
keyOrEntity
- must be a Key, Key, or registered entity. - Throws:
NullPointerException
- if keyOrEntity is nullIllegalArgumentException
- if keyOrEntity is not a Key, Key, or registered entity
-
anythingToRawKey
Gets the raw datstore Key given an object that might be a Key, Key
, or entity. - Parameters:
keyOrEntity
- must be a Key, Key, or registered entity. - Throws:
NullPointerException
- if keyOrEntity is nullIllegalArgumentException
- if keyOrEntity is not a Key, Key, or registered entity
-
getKey
public static com.google.cloud.datastore.Key getKey(com.google.cloud.datastore.FullEntity<?> entity) - Returns:
- the Key, or throw an exception if entity's key is missing or incomplete
-
requiresAutogeneratedId
- Returns:
- true of the entity has a null id which can be autogenerated on save
-
createRaw
public com.google.cloud.datastore.Key createRaw(String namespace, com.google.cloud.datastore.Key parent, String kind, long id) namespace and parent are mutually exclusive- Parameters:
parent
- can be null for root keys
-
createRaw
public com.google.cloud.datastore.Key createRaw(String namespace, com.google.cloud.datastore.Key parent, String kind, String name) namespace and parent are mutually exclusive- Parameters:
parent
- can be null for root keys
-
createRawAny
public com.google.cloud.datastore.Key createRawAny(String namespace, com.google.cloud.datastore.Key parent, String kind, Object id) Construct a Key from a Long or String id- Parameters:
id
- must be either Long or String
-
createRawIncomplete
public com.google.cloud.datastore.IncompleteKey createRawIncomplete(String namespace, com.google.cloud.datastore.Key parent, String kind) namespace and parent are mutually exclusive- Parameters:
parent
- can be null for root keys
-
createKey
namespace and parent are mutually exclusive- Parameters:
parent
- can be null for root keys
-
createKey
namespace and parent are mutually exclusive- Parameters:
parent
- can be null for root keys
-
createKeyAny
Construct a Keyinvalid input: '<'?> from a Long or String id namespace and parent are mutually exclusive- Parameters:
id
- must be either Long or String
-
raw
Null-safe extraction of the raw key -
createKeys
Make a list of Keyinvalid input: '<'?>s- Parameters:
namespace
- must be exclusive with parent; only one can be providedparent
- must be exclusive with namespace; only one can be providedids
- must contain either Long or String
-
toArray
public static com.google.cloud.datastore.Key[] toArray(Collection<com.google.cloud.datastore.Key> collection) -
getIdValue
public static <S> com.google.cloud.datastore.Value<S> getIdValue(com.google.cloud.datastore.IncompleteKey key) Gets the String or Long id from the key as a Value, or null if incomplete -
fromUrlSafe
Understands both the legacy format "ag1zfnZvb2Rvb2R5bmUwcgcLEgFCGAEM" and new format, providing the key either way. -
adjustNamespace
public static com.google.cloud.datastore.KeyFactory adjustNamespace(com.google.cloud.datastore.KeyFactory keyFactory, String namespace) Be sensitive to the thread local namespace, if set -
adjustNamespace
public static <B extends com.google.cloud.datastore.BaseKey.Builder<B>> B adjustNamespace(B builder, String namespace) Be sensitive to the thread local namespace, if set
-