renatoh commented on code in PR #3141:
URL: https://github.com/apache/solr/pull/3141#discussion_r1931638863


##########
solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java:
##########
@@ -526,4 +527,36 @@ public String toString() {
     }
     return sb.toString();
   }
+
+  /**
+   * A SolrParams is equal to another if they have the same keys and values. 
The order of keys does
+   * not matter.
+   */
+  @Override
+  public boolean equals(Object obj) {
+    if (obj == this) return true;
+    if (!(obj instanceof SolrParams b)) return false;
+
+    // iterating this params, see if other has the same values for each key
+    int count = 0;
+    for (Entry<String, String[]> thisEntry : this) {
+      String name = thisEntry.getKey();
+      if (!Arrays.equals(thisEntry.getValue(), b.getParams(name))) return 
false;
+      count++;
+    }
+    // does other params have the same number of keys?  It might have more but 
not less.
+    Iterator<String> bNames = b.getParameterNamesIterator();
+    while (bNames.hasNext()) {

Review Comment:
   I could not find a test case where x.equals(y) is not y.equals(y)
   I missed the fact, that params with the same key are combined into the same 
Array, my bad!
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to