2121import java .util .Objects ;
2222
2323import static io .nats .client .support .ApiConstants .DESCRIPTION ;
24- import static io .nats .client .support .ApiConstants .SUBJECTS ;
25- import static io .nats .client .support .JsonValueUtils . readString ;
26- import static io .nats .client .support .JsonValueUtils .readStringList ;
24+ import static io .nats .client .support .ApiConstants .ENDPOINTS ;
25+ import static io .nats .client .support .JsonUtils . listEquals ;
26+ import static io .nats .client .support .JsonValueUtils .* ;
2727
2828/**
2929 * SERVICE IS AN EXPERIMENTAL API SUBJECT TO CHANGE
@@ -32,12 +32,12 @@ public class InfoResponse extends ServiceResponse {
3232 public static final String TYPE = "io.nats.micro.v1.info_response" ;
3333
3434 private final String description ;
35- private final List <String > subjects ;
35+ private final List <Endpoint > endpoints ;
3636
37- public InfoResponse (String id , String name , String version , Map <String , String > metadata , String description , List <String > subjects ) {
37+ public InfoResponse (String id , String name , String version , Map <String , String > metadata , String description , List <Endpoint > endpoints ) {
3838 super (TYPE , id , name , version , metadata );
3939 this .description = description ;
40- this .subjects = subjects ;
40+ this .endpoints = endpoints ;
4141 }
4242
4343 public InfoResponse (byte [] jsonBytes ) {
@@ -47,13 +47,14 @@ public InfoResponse(byte[] jsonBytes) {
4747 private InfoResponse (JsonValue jv ) {
4848 super (TYPE , jv );
4949 description = readString (jv , DESCRIPTION );
50- subjects = readStringList (jv , SUBJECTS );
50+ endpoints = read (jv , ENDPOINTS , v -> listOf (v , Endpoint ::new ));
51+
5152 }
5253
5354 @ Override
5455 protected void subToJson (StringBuilder sb ) {
5556 JsonUtils .addField (sb , DESCRIPTION , description );
56- JsonUtils .addStrings (sb , SUBJECTS , subjects );
57+ JsonUtils .addJsons (sb , ENDPOINTS , endpoints );
5758 }
5859
5960 /**
@@ -65,11 +66,11 @@ public String getDescription() {
6566 }
6667
6768 /**
68- * Subjects that can be invoked
69- * @return the subjects
69+ * List of endpoints
70+ * @return the endpoints
7071 */
71- public List <String > getSubjects () {
72- return subjects ;
72+ public List <Endpoint > getEndpoints () {
73+ return endpoints ;
7374 }
7475
7576 @ Override
@@ -81,14 +82,14 @@ public boolean equals(Object o) {
8182 InfoResponse that = (InfoResponse ) o ;
8283
8384 if (!Objects .equals (description , that .description )) return false ;
84- return Objects . equals ( subjects , that .subjects );
85+ return listEquals ( endpoints , that .endpoints );
8586 }
8687
8788 @ Override
8889 public int hashCode () {
8990 int result = super .hashCode ();
9091 result = 31 * result + (description != null ? description .hashCode () : 0 );
91- result = 31 * result + (subjects != null ? subjects .hashCode () : 0 );
92+ result = 31 * result + (endpoints != null ? endpoints .hashCode () : 0 );
9293 return result ;
9394 }
9495}
0 commit comments