22
33import com .fasterxml .jackson .annotation .JsonAnyGetter ;
44import com .fasterxml .jackson .annotation .JsonAnySetter ;
5+ import com .fasterxml .jackson .annotation .JsonInclude ;
56import com .fasterxml .jackson .annotation .JsonProperty ;
67import java .time .Instant ;
78import java .util .Collections ;
@@ -24,16 +25,33 @@ public record SearchRequest(String query, ServiceFilters filters, Integer limit)
2425 }
2526 }
2627
28+ @ JsonInclude (JsonInclude .Include .NON_EMPTY )
2729 public record ServiceFilters (
2830 List <ServiceDocument .EnrollmentProtocol > enrollment ,
2931 List <String > keywords ,
3032 List <OperationFilter > operations ,
31- List <PaymentFilter > payments ) {
33+ List <PaymentFilter > payments ,
34+ List <ServiceDocument .TrustProtocol > trust ) {
35+ public ServiceFilters (
36+ List <ServiceDocument .EnrollmentProtocol > enrollment ,
37+ List <String > keywords ,
38+ List <OperationFilter > operations ,
39+ List <PaymentFilter > payments ) {
40+ this (enrollment , keywords , operations , payments , null );
41+ }
42+
3243 public ServiceFilters {
44+ if (trust != null
45+ && (trust .size () != 1
46+ || trust .get (0 ) == null
47+ || !"tap" .equals (trust .get (0 ).name ()))) {
48+ throw new IllegalArgumentException ("trust must contain exactly one tap descriptor" );
49+ }
3350 enrollment = enrollment == null ? List .of () : List .copyOf (enrollment );
3451 keywords = keywords == null ? List .of () : List .copyOf (keywords );
3552 operations = operations == null ? List .of () : List .copyOf (operations );
3653 payments = payments == null ? List .of () : List .copyOf (payments );
54+ trust = trust == null ? List .of () : List .copyOf (trust );
3755 }
3856 }
3957
@@ -77,13 +95,24 @@ public record Facets(
7795 List <Facet <String >> keywords ,
7896 List <Facet <OperationDescriptor >> operations ,
7997 List <Facet <ServiceDocument .PaymentProtocol >> payments ,
80- @ JsonProperty ("payment_options" ) List <Facet <PaymentOptionFacetValue >> paymentOptions ) {
98+ @ JsonProperty ("payment_options" ) List <Facet <PaymentOptionFacetValue >> paymentOptions ,
99+ List <Facet <ServiceDocument .TrustProtocol >> trust ) {
100+ public Facets (
101+ List <Facet <ServiceDocument .EnrollmentProtocol >> enrollment ,
102+ List <Facet <String >> keywords ,
103+ List <Facet <OperationDescriptor >> operations ,
104+ List <Facet <ServiceDocument .PaymentProtocol >> payments ,
105+ List <Facet <PaymentOptionFacetValue >> paymentOptions ) {
106+ this (enrollment , keywords , operations , payments , paymentOptions , null );
107+ }
108+
81109 public Facets {
82110 enrollment = enrollment == null ? List .of () : List .copyOf (enrollment );
83111 keywords = keywords == null ? List .of () : List .copyOf (keywords );
84112 operations = operations == null ? List .of () : List .copyOf (operations );
85113 payments = payments == null ? List .of () : List .copyOf (payments );
86114 paymentOptions = paymentOptions == null ? List .of () : List .copyOf (paymentOptions );
115+ trust = trust == null ? List .of () : List .copyOf (trust );
87116 }
88117 }
89118
0 commit comments