public class DatastoreServiceObjectToKeyFactory extends Object implements ObjectToKeyFactory
ObjectToKeyFactory
where the key factories are provided by the
Datastore Service.Constructor and Description |
---|
DatastoreServiceObjectToKeyFactory(Supplier<Datastore> datastore) |
Modifier and Type | Method and Description |
---|---|
Key |
allocateKeyForObject(Object entity,
DatastorePersistentEntity datastorePersistentEntity,
Key... ancestors)
Allocates a new ID
Key for the given entity object and sets the allocated ID value in
the object. |
IncompleteKey |
getIncompleteKey(String kindName)
Get an
IncompleteKey (a Key without ID part) from a kind name. |
Key |
getKeyFromId(Object id,
String kindName)
Get a
Key from a provided ID value and a kind name. |
Key |
getKeyFromObject(Object entity,
DatastorePersistentEntity datastorePersistentEntity)
Get a
Key from an entity. |
public IncompleteKey getIncompleteKey(String kindName)
ObjectToKeyFactory
IncompleteKey
(a Key without ID part) from a kind name.getIncompleteKey
in interface ObjectToKeyFactory
kindName
- the kind namepublic Key getKeyFromId(Object id, String kindName)
ObjectToKeyFactory
Key
from 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.getKeyFromId
in interface ObjectToKeyFactory
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.public Key getKeyFromObject(Object entity, DatastorePersistentEntity datastorePersistentEntity)
ObjectToKeyFactory
Key
from an entity.getKeyFromObject
in interface ObjectToKeyFactory
entity
- the entity that whose ID value we want to form into a Key.datastorePersistentEntity
- the metadata of the given entity.public Key allocateKeyForObject(Object entity, DatastorePersistentEntity datastorePersistentEntity, Key... ancestors)
ObjectToKeyFactory
Key
for the given entity object and sets the allocated ID value in
the object. Only Key ids are allowed in entities if ancestors are present.allocateKeyForObject
in interface ObjectToKeyFactory
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 entityCopyright © 2022. All rights reserved.