File tree Expand file tree Collapse file tree
src/main/java/io/weaviate/client6/v1/internal/rest Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import java .util .Map ;
77import java .util .stream .Collectors ;
88
9- public final class UrlEncoder {
9+ final class UrlEncoder {
1010
1111 private static String encodeValue (Object value ) {
1212 try {
@@ -16,11 +16,28 @@ private static String encodeValue(Object value) {
1616 }
1717 }
1818
19+ /**
20+ * Encodes each key-value pair into a URL-compatible query string, omitting any
21+ * {@code null} or blank (in case of String parameter) values.
22+ * Each value is represented by the return of its [@conde toString()} method.
23+ *
24+ * @return URL query string or empty string if the map was empty
25+ * or contained no valid parameters.
26+ */
1927 public static String encodeQuery (Map <String , Object > queryParams ) {
2028 if (queryParams == null || queryParams .isEmpty ()) {
2129 return "" ;
2230 }
2331 return queryParams .entrySet ().stream ()
32+ .filter (qp -> {
33+ if (qp == null ) {
34+ return false ;
35+ }
36+ if (qp .getValue () instanceof String str ) {
37+ return !str .isBlank ();
38+ }
39+ return true ;
40+ })
2441 .map (qp -> qp .getKey () + "=" + encodeValue (qp .getValue ()))
2542 .collect (Collectors .joining ("&" , "?" , "" ));
2643 }
You can’t perform that action at this time.
0 commit comments