NebulaGraph Java Client  release-3.8
HostAddress.java
1 /* Copyright (c) 2020 vesoft inc. All rights reserved.
2  *
3  * This source code is licensed under Apache 2.0 License.
4  */
5 
6 package com.vesoft.nebula.client.graph.data;
7 
8 import java.io.Serializable;
9 
10 public class HostAddress implements Serializable {
11  private final String host;
12  private final int port;
13 
14  public HostAddress(String host, int port) {
15  this.host = host;
16  this.port = port;
17  }
18 
19  public String getHost() {
20  return host;
21  }
22 
23  public int getPort() {
24  return port;
25  }
26 
27  @Override
28  public int hashCode() {
29  return host.hashCode() + port;
30  }
31 
32  @Override
33  public boolean equals(Object obj) {
34  if (this == obj) {
35  return true;
36  }
37  if (obj instanceof HostAddress) {
38  HostAddress that = (HostAddress) obj;
39  return this.host.equals(that.host) && this.port == that.port;
40  }
41  return false;
42  }
43 
44  @Override
45  public String toString() {
46  return host + ":" + port;
47  }
48 }