Class DatabaseDestination

java.lang.Object
io.github.flink.gcp.connector.datastore.DatabaseDestination
All Implemented Interfaces:
Serializable

@PublicEvolving public final class DatabaseDestination extends Object implements Serializable
A Firestore database in Datastore mode: a project and a database id.

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 Details

    • DEFAULT_DATABASE_NAME

      public static final String DEFAULT_DATABASE_NAME
      The name every project's default database goes by outside the Datastore API.
      See Also:
  • Method Details

    • of

      public static DatabaseDestination of(String project)
      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

      public static DatabaseDestination of(String project, String databaseId)
      Creates a reference to a named database.
      Parameters:
      project - the Google Cloud project id, as a bare id rather than a resource path
      databaseId - the database id; the empty id and "(default)" both address the default database, as of(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

      public String getProject()
      Returns the Google Cloud project id.
    • getDatabaseId

      public String getDatabaseId()
      Returns the database id as the Datastore API spells it: empty for the default database.
      Returns:
      the database id
    • toString

      public String toString()
      Returns the database as a resource name, projects/P/databases/D, with "(default)" for the default database.
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object