Class PgUrlParser

java.lang.Object
io.github.mfvanek.pg.connection.host.PgUrlParser

public final class PgUrlParser extends Object
Utility class for parsing and manipulating PostgreSQL connection URLs.
  • Field Details

  • Method Details

    • extractNameWithPortAndUrlForEachHost

      @Nonnull public static List<Map.Entry<String,String>> extractNameWithPortAndUrlForEachHost(@Nonnull String pgUrl)
      Extracts host-port pairs and builds replica-compatible connection URLs for each host.
      Parameters:
      pgUrl - the PostgreSQL connection URL; must be valid and non-blank.
      Returns:
      a list of host-port pairs and corresponding replica-compatible URLs.
    • buildCommonUrlToPrimary

      @Nonnull public static String buildCommonUrlToPrimary(@Nonnull String firstPgUrl, @Nonnull String secondPgUrl)
      Constructs a common (joint) PostgreSQL URL for a primary server.
      Parameters:
      firstPgUrl - a first PostgreSQL connection URL.
      secondPgUrl - a second PostgreSQL connection URL.
      Returns:
      the constructed primary connection URL.
    • buildCommonUrlToPrimary

      @Nonnull public static String buildCommonUrlToPrimary(@Nonnull String firstPgUrl, @Nonnull String secondPgUrl, @Nonnull Map<String,String> urlParameters)
      Constructs a common (joint) PostgreSQL URL for a primary server.
      Parameters:
      firstPgUrl - a first PostgreSQL connection URL.
      secondPgUrl - a second PostgreSQL connection URL.
      urlParameters - optional additional parameters to include in the URL.
      Returns:
      the constructed primary connection URL.
    • buildCommonUrlToPrimary

      @Nonnull public static String buildCommonUrlToPrimary(@Nonnull Set<String> pgUrls)
      Constructs a common (joint) PostgreSQL URL for a primary server.
      Parameters:
      pgUrls - a set of PostgreSQL connection URLs.
      Returns:
      the constructed primary connection URL.
    • buildCommonUrlToPrimary

      @Nonnull public static String buildCommonUrlToPrimary(@Nonnull Set<String> pgUrls, @Nonnull Map<String,String> urlParameters)
      Constructs a common (joint) PostgreSQL URL for a primary server.
      Parameters:
      pgUrls - a set of PostgreSQL connection URLs.
      urlParameters - optional additional parameters to include in the URL.
      Returns:
      the constructed primary connection URL.