Class DatastoreServiceObjectToKeyFactory
java.lang.Object
com.google.cloud.spring.data.datastore.core.convert.DatastoreServiceObjectToKeyFactory
- All Implemented Interfaces:
ObjectToKeyFactory
Implementation of
ObjectToKeyFactory where the key factories are provided by the
Datastore Service.- Since:
- 1.1
-
Constructor Summary
ConstructorsConstructorDescriptionDatastoreServiceObjectToKeyFactory(Supplier<com.google.cloud.datastore.Datastore> datastore) -
Method Summary
Modifier and TypeMethodDescriptioncom.google.cloud.datastore.KeyallocateKeyForObject(Object entity, DatastorePersistentEntity datastorePersistentEntity, com.google.cloud.datastore.Key... ancestors) Allocates a new IDKeyfor the given entity object and sets the allocated ID value in the object.com.google.cloud.datastore.IncompleteKeygetIncompleteKey(String kindName) Get anIncompleteKey(a Key without ID part) from a kind name.com.google.cloud.datastore.KeygetKeyFromId(Object id, String kindName) Get aKeyfrom a provided ID value and a kind name.com.google.cloud.datastore.KeygetKeyFromObject(Object entity, DatastorePersistentEntity datastorePersistentEntity) Get aKeyfrom an entity.
-
Constructor Details
-
DatastoreServiceObjectToKeyFactory
-
-
Method Details
-
getIncompleteKey
Description copied from interface:ObjectToKeyFactoryGet anIncompleteKey(a Key without ID part) from a kind name.- Specified by:
getIncompleteKeyin interfaceObjectToKeyFactory- Parameters:
kindName- the kind name- Returns:
- an IncompleteKey.
-
getKeyFromId
Description copied from interface:ObjectToKeyFactoryGet aKeyfrom a provided ID value and a kind name. If the given ID value is already a Key then this is the Key returned. Otherwise a Key is created with the given kind name and the given ID value as the only and root value.- Specified by:
getKeyFromIdin interfaceObjectToKeyFactory- Parameters:
id- the ID value that can be the root single ID value or a fully formed Key.kindName- the kind name used if the ID value provided is not a fully formed Key.- Returns:
- a Key.
-
getKeyFromObject
public com.google.cloud.datastore.Key getKeyFromObject(Object entity, DatastorePersistentEntity datastorePersistentEntity) Description copied from interface:ObjectToKeyFactoryGet aKeyfrom an entity.- Specified by:
getKeyFromObjectin interfaceObjectToKeyFactory- Parameters:
entity- the entity that whose ID value we want to form into a Key.datastorePersistentEntity- the metadata of the given entity.- Returns:
- a Key.
-
allocateKeyForObject
public com.google.cloud.datastore.Key allocateKeyForObject(Object entity, DatastorePersistentEntity datastorePersistentEntity, com.google.cloud.datastore.Key... ancestors) Description copied from interface:ObjectToKeyFactoryAllocates a new IDKeyfor the given entity object and sets the allocated ID value in the object. Only Key ids are allowed in entities if ancestors are present.- Specified by:
allocateKeyForObjectin interfaceObjectToKeyFactory- Parameters:
entity- the object for which to get and set the ID value.datastorePersistentEntity- the persistent entity metadata for the entity object.ancestors- ancestors that should be added to the entity- Returns:
- the newly allocated Key.
-