All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.postgresql.util.HostSpec Maven / Gradle / Ivy

There is a newer version: 8.1.2
Show newest version
/*
 * Copyright (c) 2012, PostgreSQL Global Development Group
 * See the LICENSE file in the project root for more information.
 */

package org.postgresql.util;

/**
 * Simple container for host and port.
 */
public class HostSpec {
  protected final String host;
  protected final int port;

  public HostSpec(String host, int port) {
    this.host = host;
    this.port = port;
  }

  public String getHost() {
    return host;
  }

  public int getPort() {
    return port;
  }

  public String toString() {
    return host + ":" + port;
  }

  @Override
  public boolean equals(Object obj) {
    return obj instanceof HostSpec && port == ((HostSpec) obj).port
        && host.equals(((HostSpec) obj).host);
  }

  @Override
  public int hashCode() {
    return port ^ host.hashCode();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy