Class DatabaseDestination
- All Implemented Interfaces:
Serializable
A database, not a kind, is as far as the sink's destination goes: every entity carries its own key, and kinds and namespaces are implicit in Datastore — the first write into one creates it. That is why the sink takes no destination resolver and has nothing to create.
The Datastore API names the default database with an empty id, and refuses the "(default)" spelling Native mode uses. of(String) addresses the default
database, and so does of(String, String) given the empty id or "(default)": getDatabaseId() returns the empty id for both, which is what
the client library and a Key built without a database id carry.
Instances are pure database identity: equals(Object) and hashCode()
are defined over exactly (project, database id). How the client reaches the database — an
emulator endpoint, a service-account key — belongs to the direction that takes it.
Instances are immutable and cheap to reuse.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name every project's default database goes by outside the Datastore API. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the database id as the Datastore API spells it: empty for the default database.Returns the Google Cloud project id.inthashCode()static DatabaseDestinationCreates a reference to a project's default database.static DatabaseDestinationCreates a reference to a named database.toString()Returns the database as a resource name,projects/P/databases/D, with "(default)" for the default database.
-
Field Details
-
DEFAULT_DATABASE_NAME
The name every project's default database goes by outside the Datastore API.- See Also:
-
-
Method Details
-
of
Creates a reference to a project's default database.- Parameters:
project- the Google Cloud project id, as a bare id rather than a resource path- Returns:
- the database reference
- Throws:
IllegalArgumentException- if the project is null or blank, has leading or trailing whitespace, or contains'/'— a separator would make the composed resource path address a different resource
-
of
Creates a reference to a named database.- Parameters:
project- the Google Cloud project id, as a bare id rather than a resource pathdatabaseId- the database id; the empty id and "(default)" both address the default database, asof(String)does- Returns:
- the database reference
- Throws:
IllegalArgumentException- if a component is null or blank, has leading or trailing whitespace, or contains'/'— a separator would make the composed resource path address a different resource
-
getProject
Returns the Google Cloud project id. -
getDatabaseId
Returns the database id as the Datastore API spells it: empty for the default database.- Returns:
- the database id
-
toString
Returns the database as a resource name,projects/P/databases/D, with "(default)" for the default database. -
equals
-
hashCode
public int hashCode()
-