1+ package com .xxdb .replicator ;
2+
3+ /**
4+ * Host information for StreamReplicator connection.
5+ * Contains connection details for a DolphinDB server node.
6+ */
7+ public class HostInfo {
8+ private final String host ;
9+ private final int port ;
10+ private final String userId ;
11+ private final String password ;
12+ private final String label ;
13+
14+ /**
15+ * Creates a new HostInfo with the specified connection details.
16+ *
17+ * @param host The hostname or IP address of the DolphinDB server
18+ * @param port The port number of the DolphinDB server
19+ * @param userId The user ID for authentication
20+ * @param password The password for authentication
21+ * @param label A unique label to identify this host
22+ */
23+ public HostInfo (String host , int port , String userId , String password , String label ) {
24+ if (host == null || host .isEmpty ()) {
25+ throw new IllegalArgumentException ("The param 'host' cannot be null or empty." );
26+ }
27+
28+ if (port <= 0 || port > 65535 ) {
29+ throw new IllegalArgumentException ("The param 'port' must be between 1 and 65535." );
30+ }
31+
32+ if (label == null || label .isEmpty ()) {
33+ throw new IllegalArgumentException ("The param 'label' cannot be null or empty." );
34+ }
35+
36+ this .host = host ;
37+ this .port = port ;
38+ this .userId = userId ;
39+ this .password = password ;
40+ this .label = label ;
41+ }
42+
43+ public String getHost () {
44+ return host ;
45+ }
46+
47+ public int getPort () {
48+ return port ;
49+ }
50+
51+ public String getUserId () {
52+ return userId ;
53+ }
54+
55+ public String getPassword () {
56+ return password ;
57+ }
58+
59+ public String getLabel () {
60+ return label ;
61+ }
62+
63+ @ Override
64+ public String toString () {
65+ return String .format ("HostInfo{label='%s', host='%s', port=%d, userId='%s'}" ,
66+ label , host , port , userId );
67+ }
68+
69+ @ Override
70+ public boolean equals (Object o ) {
71+ if (this == o ) return true ;
72+ if (o == null || getClass () != o .getClass ()) return false ;
73+ HostInfo hostInfo = (HostInfo ) o ;
74+ return port == hostInfo .port &&
75+ host .equals (hostInfo .host ) &&
76+ label .equals (hostInfo .label );
77+ }
78+
79+ @ Override
80+ public int hashCode () {
81+ int result = host .hashCode ();
82+ result = 31 * result + port ;
83+ result = 31 * result + label .hashCode ();
84+ return result ;
85+ }
86+ }
0 commit comments