public static final class KeyFactory.BuilderHelper 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 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();
Constructors
Builder(Key key)
public Builder(Key key)Create a Builder, establishing the provided Key as the topmost ancestor.
| Parameter | |
|---|---|
| Name | Description |
key |
Keythe topmost ancestor |
Builder(String kind, String name)
public Builder(String kind, String name)Create a Builder, establishing a Key constructed from the provided kind and
name as the topmost ancestor.
| Parameters | |
|---|---|
| Name | Description |
kind |
Stringthe kind of the topmost ancestor |
name |
Stringthe name of the topmost ancestor in |
Builder(String kind, long id)
public Builder(String kind, long id)Create a Builder, establishing a Key constructed from the provided kind and
id as the topmost ancestor.
| Parameters | |
|---|---|
| Name | Description |
kind |
Stringthe kind of the topmost ancestor |
id |
longthe numeric identifier of the topmost ancestor in |
Methods
addChild(String kind, String name)
public KeyFactory.Builder addChild(String kind, String name)Add a Key constructed from the provided kind and name as the child of the Key
most recently added to the Builder.
| Parameters | |
|---|---|
| Name | Description |
kind |
Stringthe kind of the child |
name |
Stringthe name of the child in |
| Returns | |
|---|---|
| Type | Description |
KeyFactory.Builder |
|
addChild(String kind, long id)
public KeyFactory.Builder addChild(String kind, long id)Add a Key constructed from the provided kind and id as the child of the Key
most recently added to the Builder.
| Parameters | |
|---|---|
| Name | Description |
kind |
Stringthe kind of the child |
id |
longthe numeric identifier of the child in |
| Returns | |
|---|---|
| Type | Description |
KeyFactory.Builder |
|
getKey()
public Key getKey()Returns the most recently added Key.
| Returns | |
|---|---|
| Type | Description |
Key |
|
getString()
public String getString()| Returns | |
|---|---|
| Type | Description |
String |
|