Class KeyFactory.Builder
java.lang.Object
com.google.appengine.api.datastore.KeyFactory.Builder
- Enclosing class:
KeyFactory
Helper class that aids in the construction of
Keys
with ancestors. Initialize the
Builder
with the topmost ancestor in your key path and then add children using the
addChild(java.lang.String, java.lang.String)
overload that best suits your needs. When finished adding children, call
getKey()
to retrieve your Key
or getString()
to retrieve your Key
encoded as a websafe String
.
Examples:
import com.google.appengine.api.datastore.KeyFactory.Builder;
...
Key key = new Builder("Person", 88).addChild("Address", 24).getKey();
String keyStr = new Builder("Photo Album", "Vacation").addChild("Photo", 1424).getString();
-
Constructor Summary
ConstructorsConstructorDescriptionCreate aBuilder
, establishing the providedKey
as the topmost ancestor.Create aBuilder
, establishing aKey
constructed from the provided kind and id as the topmost ancestor.Create aBuilder
, establishing aKey
constructed from the provided kind and name as the topmost ancestor. -
Method Summary
-
Constructor Details
-
Builder
Create aBuilder
, establishing aKey
constructed from the provided kind and name as the topmost ancestor.- Parameters:
kind
- the kind of the topmost ancestorname
- the name of the topmost ancestor inkind
, as an arbitrary string unique across root entities of thiskind
-
Builder
Create aBuilder
, establishing aKey
constructed from the provided kind and id as the topmost ancestor.- Parameters:
kind
- the kind of the topmost ancestorid
- the numeric identifier of the topmost ancestor inkind
, unique across root entities of this kind, must not be zero
-
Builder
Create aBuilder
, establishing the providedKey
as the topmost ancestor.- Parameters:
key
- the topmost ancestor
-
-
Method Details
-
addChild
Add aKey
constructed from the provided kind and name as the child of theKey
most recently added to theBuilder
.- Parameters:
kind
- the kind of the childname
- the name of the child inkind
, as an arbitrary string unique across entities of thiskind
with the same parent- Returns:
this
-
addChild
Add aKey
constructed from the provided kind and id as the child of theKey
most recently added to theBuilder
.- Parameters:
kind
- the kind of the childid
- the numeric identifier of the child inkind
, unique across entities of this kind with the same parent, must not be zero- Returns:
this
-
getKey
Returns the most recently addedKey
. -
getString
-