2222
2323import static io .nats .client .support .ApiConstants .*;
2424import static io .nats .client .support .JsonUtils .endJson ;
25- import static io .nats .client .support .JsonValueUtils .*;
25+ import static io .nats .client .support .JsonValueUtils .readString ;
26+ import static io .nats .client .support .JsonValueUtils .readStringStringMap ;
2627import static io .nats .client .support .Validator .validateIsRestrictedTerm ;
2728import static io .nats .client .support .Validator .validateSubject ;
2829
3233public class Endpoint implements JsonSerializable {
3334 private final String name ;
3435 private final String subject ;
35- private final Schema schema ;
3636 private final Map <String , String > metadata ;
3737
38- public Endpoint (String name , String subject , Schema schema ) {
39- this (name , subject , schema , null , true );
40- }
41-
4238 public Endpoint (String name ) {
43- this (name , null , null , null , true );
39+ this (name , null , null , true );
4440 }
4541
4642 public Endpoint (String name , String subject ) {
47- this (name , subject , null , null , true );
48- }
49-
50- public Endpoint (String name , String subject , String schemaRequest , String schemaResponse ) {
51- this (name , subject , Schema .optionalInstance (schemaRequest , schemaResponse ), null , true );
43+ this (name , subject , null , true );
5244 }
5345
5446 // internal use constructors
55- Endpoint (String name , String subject , Schema schema , Map <String , String > metadata , boolean validate ) {
47+ Endpoint (String name , String subject , Map <String , String > metadata , boolean validate ) {
5648 if (validate ) {
5749 this .name = validateIsRestrictedTerm (name , "Endpoint Name" , true );
5850 if (subject == null ) {
@@ -66,27 +58,24 @@ public Endpoint(String name, String subject, String schemaRequest, String schema
6658 this .name = name ;
6759 this .subject = subject ;
6860 }
69- this .schema = schema ;
7061 this .metadata = metadata == null || metadata .size () == 0 ? null : metadata ;
7162 }
7263
7364 Endpoint (JsonValue vEndpoint ) {
7465 name = readString (vEndpoint , NAME );
7566 subject = readString (vEndpoint , SUBJECT );
76- schema = Schema .optionalInstance (readValue (vEndpoint , SCHEMA ));
7767 metadata = readStringStringMap (vEndpoint , METADATA );
7868 }
7969
8070 Endpoint (Builder b ) {
81- this (b .name , b .subject , Schema . optionalInstance ( b . schemaRequest , b . schemaResponse ), b .metadata , true );
71+ this (b .name , b .subject , b .metadata , true );
8272 }
8373
8474 @ Override
8575 public String toJson () {
8676 StringBuilder sb = JsonUtils .beginJson ();
8777 JsonUtils .addField (sb , NAME , name );
8878 JsonUtils .addField (sb , SUBJECT , subject );
89- JsonUtils .addField (sb , SCHEMA , schema );
9079 JsonUtils .addField (sb , METADATA , metadata );
9180 return endJson (sb ).toString ();
9281 }
@@ -104,10 +93,6 @@ public String getSubject() {
10493 return subject ;
10594 }
10695
107- public Schema getSchema () {
108- return schema ;
109- }
110-
11196 public Map <String , String > getMetadata () {
11297 return metadata ;
11398 }
@@ -119,22 +104,11 @@ public static Builder builder() {
119104 public static class Builder {
120105 private String name ;
121106 private String subject ;
122- private String schemaRequest ;
123- private String schemaResponse ;
124107 private Map <String , String > metadata ;
125108
126109 public Builder endpoint (Endpoint endpoint ) {
127110 name = endpoint .getName ();
128111 subject = endpoint .getSubject ();
129- Schema s = endpoint .getSchema ();
130- if (s == null ) {
131- schemaRequest = null ;
132- schemaResponse = null ;
133- }
134- else {
135- schemaRequest = s .getRequest ();
136- schemaResponse = s .getResponse ();
137- }
138112 return this ;
139113 }
140114
@@ -148,28 +122,6 @@ public Builder subject(String subject) {
148122 return this ;
149123 }
150124
151- public Builder schemaRequest (String schemaRequest ) {
152- this .schemaRequest = schemaRequest ;
153- return this ;
154- }
155-
156- public Builder schemaResponse (String schemaResponse ) {
157- this .schemaResponse = schemaResponse ;
158- return this ;
159- }
160-
161- public Builder schema (Schema schema ) {
162- if (schema == null ) {
163- schemaRequest = null ;
164- schemaResponse = null ;
165- }
166- else {
167- schemaRequest = schema .getRequest ();
168- schemaResponse = schema .getResponse ();
169- }
170- return this ;
171- }
172-
173125 public Builder metadata (Map <String , String > metadata ) {
174126 this .metadata = metadata ;
175127 return this ;
@@ -189,15 +141,13 @@ public boolean equals(Object o) {
189141
190142 if (!Objects .equals (name , that .name )) return false ;
191143 if (!Objects .equals (subject , that .subject )) return false ;
192- if (!Objects .equals (schema , that .schema )) return false ;
193144 return JsonUtils .mapEquals (metadata , that .metadata );
194145 }
195146
196147 @ Override
197148 public int hashCode () {
198149 int result = name != null ? name .hashCode () : 0 ;
199150 result = 31 * result + (subject != null ? subject .hashCode () : 0 );
200- result = 31 * result + (schema != null ? schema .hashCode () : 0 );
201151 result = 31 * result + (metadata != null ? metadata .hashCode () : 0 );
202152 return result ;
203153 }
0 commit comments