1313
1414package io .nats ;
1515
16+ import org .jspecify .annotations .NullMarked ;
17+ import org .jspecify .annotations .NullUnmarked ;
18+ import org .jspecify .annotations .Nullable ;
19+
1620import java .nio .file .Path ;
1721
22+ /**
23+ * An object representing a single server node
24+ */
25+ @ NullMarked
1826public class ClusterNode {
27+ /** The name of the cluster */
1928 public final String clusterName ;
29+ /** The name of the server */
2030 public final String serverName ;
31+ /** The port */
2132 public final int port ;
33+ /** The listen port */
2234 public final int listen ;
23- public final String host ;
24- public final Integer monitor ;
25- public final Path jsStoreDir ;
26-
35+ /** The host */
36+ @ Nullable public final String host ;
37+ /** The monitor port, may be null */
38+ @ Nullable public final Integer monitor ;
39+ /** A custom path to use as the JetStream storage directory */
40+ @ Nullable public final Path jsStoreDir ;
41+
42+ /**
43+ * Construct a ClusterNode
44+ * @param clusterName the cluster name
45+ * @param serverName the server name
46+ * @param port the port
47+ * @param listen the listen port
48+ */
2749 public ClusterNode (String clusterName , String serverName , int port , int listen ) {
2850 this (clusterName , serverName , null , port , listen , null , null );
2951 }
3052
31- public ClusterNode (String clusterName , String serverName , int port , int listen , Integer monitor ) {
53+ /**
54+ * Construct a ClusterNode
55+ * @param clusterName the cluster name
56+ * @param serverName the server name
57+ * @param port the port
58+ * @param listen the listen port
59+ */
60+ public ClusterNode (String clusterName , String serverName , int port , int listen , @ Nullable Integer monitor ) {
3261 this (clusterName , serverName , null , port , listen , monitor , null );
3362 }
3463
35- public ClusterNode (String clusterName , String serverName , int port , int listen , Path jsStoreDir ) {
64+ public ClusterNode (String clusterName , String serverName , int port , int listen , @ Nullable Path jsStoreDir ) {
3665 this (clusterName , serverName , null , port , listen , null , jsStoreDir );
3766 }
3867
39- public ClusterNode (String clusterName , String serverName , String host , int port , int listen , Integer monitor , Path jsStoreDir ) {
68+ public ClusterNode (String clusterName , String serverName , @ Nullable String host , int port , int listen , @ Nullable Integer monitor , @ Nullable Path jsStoreDir ) {
4069 this .clusterName = clusterName ;
4170 this .serverName = serverName ;
4271 this .host = host ;
@@ -46,15 +75,29 @@ public ClusterNode(String clusterName, String serverName, String host, int port,
4675 this .jsStoreDir = jsStoreDir ;
4776 }
4877
78+ @ Override
79+ public String toString () {
80+ return "ClusterNode{" +
81+ "clusterName='" + clusterName + '\'' +
82+ ", serverName='" + serverName + '\'' +
83+ ", port=" + port +
84+ ", listen=" + listen +
85+ ", host='" + host + '\'' +
86+ ", monitor=" + monitor +
87+ ", jsStoreDir=" + jsStoreDir +
88+ '}' ;
89+ }
90+
4991 public static Builder builder () {
5092 return new Builder ();
5193 }
5294
95+ @ NullUnmarked
5396 public static class Builder {
5497 private String clusterName ;
5598 private String serverName ;
56- private int port ;
57- private int listen ;
99+ private int port = - 1 ;
100+ private int listen = - 1 ;
58101 private String host ;
59102 private Integer monitor ;
60103 private Path jsStoreDir ;
0 commit comments