Record Class SourceSpec

java.lang.Object
java.lang.Record
com.enhancedechest.migration.SourceSpec
Record Components:
type - backend type: sqlite, mysql, mariadb, postgres or postgresql
sqliteFile - SQLite database file (absolute, or relative to the plugin data folder); SQLite only
host - remote host; MySQL/MariaDB/PostgreSQL only
port - remote port; MySQL/MariaDB/PostgreSQL only
database - remote database name; MySQL/MariaDB/PostgreSQL only
username - remote username; MySQL/MariaDB/PostgreSQL only
password - remote password (shown in cleartext in the dialog — documented); MySQL/MariaDB/PostgreSQL only

public record SourceSpec(String type, String sqliteFile, String host, int port, String database, String username, String password) extends Record
Connection details for the source database of a /ee import DB→DB conversion, as filled in by the import dialog. The destination is always the plugin's active backend; this describes the old backend the admin is copying from.

Only the fields relevant to type are used: sqliteFile for SQLite, and host/port/database/username/password for the remote engines. The other fields are ignored (the dialog is static and shows every field regardless of type).

  • Constructor Summary

    Constructors
    Constructor
    Description
    SourceSpec(String type, String sqliteFile, String host, int port, String database, String username, String password)
    Creates an instance of a SourceSpec record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the database record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static String
    family(@Nullable String type)
    Collapses driver aliases to a family: mariadb→mysql, postgresql→postgres.
    final int
    Returns a hash code value for this object.
    Returns the value of the host record component.
    static String
    identity(String type, String sqliteFile, String host, int port, String database, Path dataFolder)
    Builds the same identity string from raw parts (used for the active destination config too).
    identity(Path dataFolder)
    A stable identity string for equality checks against the active destination, so an import that would read from the very database it is writing into can be refused.
    boolean
    True when this spec describes a file-based SQLite source.
    Returns the value of the password record component.
    int
    Returns the value of the port record component.
    Returns the value of the sqliteFile record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.
    Returns the value of the username record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SourceSpec

      public SourceSpec(String type, String sqliteFile, String host, int port, String database, String username, String password)
      Creates an instance of a SourceSpec record class.
      Parameters:
      type - the value for the type record component
      sqliteFile - the value for the sqliteFile record component
      host - the value for the host record component
      port - the value for the port record component
      database - the value for the database record component
      username - the value for the username record component
      password - the value for the password record component
  • Method Details

    • isSqlite

      public boolean isSqlite()
      True when this spec describes a file-based SQLite source.
    • identity

      public String identity(Path dataFolder)
      A stable identity string for equality checks against the active destination, so an import that would read from the very database it is writing into can be refused. Two specs/backends pointing at the same database produce the same identity: for SQLite the absolute file path, otherwise the engine family plus host:port/database (host case-insensitive).
      Parameters:
      dataFolder - plugin data folder, used to resolve a relative SQLite file path
    • identity

      public static String identity(String type, String sqliteFile, String host, int port, String database, Path dataFolder)
      Builds the same identity string from raw parts (used for the active destination config too).
    • family

      public static String family(@Nullable @Nullable String type)
      Collapses driver aliases to a family: mariadb→mysql, postgresql→postgres.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • sqliteFile

      public String sqliteFile()
      Returns the value of the sqliteFile record component.
      Returns:
      the value of the sqliteFile record component
    • host

      public String host()
      Returns the value of the host record component.
      Returns:
      the value of the host record component
    • port

      public int port()
      Returns the value of the port record component.
      Returns:
      the value of the port record component
    • database

      public String database()
      Returns the value of the database record component.
      Returns:
      the value of the database record component
    • username

      public String username()
      Returns the value of the username record component.
      Returns:
      the value of the username record component
    • password

      public String password()
      Returns the value of the password record component.
      Returns:
      the value of the password record component