From 59de19bbeffa5a092480ec361f95fbe52630fdf4 Mon Sep 17 00:00:00 2001
From: Christine Poerschke <cpoerschke@apache.org>
Date: Mon, 9 Sep 2024 13:00:28 +0100
Subject: [PATCH] remove deprecated SolrParams methods

---
 .../apache/solr/search/facet/FacetParser.java |  2 +-
 .../solr/search/TestMinHashQParser.java       |  5 +-
 .../apache/solr/common/params/SolrParams.java | 90 -------------------
 3 files changed, 3 insertions(+), 94 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetParser.java b/solr/core/src/java/org/apache/solr/search/facet/FacetParser.java
index 6ef55cb4be1..ce1276788d5 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/FacetParser.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/FacetParser.java
@@ -454,7 +454,7 @@ public static SolrParams jsonToSolrParams(Map jsonObject) {
     // HACK, but NamedList already handles the list processing for us...
     NamedList<String> nl = new NamedList<>();
     nl.addAll(jsonObject);
-    return SolrParams.toSolrParams(nl);
+    return nl.toSolrParams();
   }
 
   // TODO Make this private (or at least not static) and introduce
diff --git a/solr/core/src/test/org/apache/solr/search/TestMinHashQParser.java b/solr/core/src/test/org/apache/solr/search/TestMinHashQParser.java
index d8f678cb3f1..45457356de6 100644
--- a/solr/core/src/test/org/apache/solr/search/TestMinHashQParser.java
+++ b/solr/core/src/test/org/apache/solr/search/TestMinHashQParser.java
@@ -417,8 +417,7 @@ public void testBandsWrap() throws SyntaxError {
     QParser qparser =
         h.getCore()
             .getQueryPlugin("minhash")
-            .createParser(
-                "1, 2, 3, 4, 5, 6, 7, 8, 9, 10", SolrParams.toSolrParams(par), null, null);
+            .createParser("1, 2, 3, 4, 5, 6, 7, 8, 9, 10", par.toSolrParams(), null, null);
     Query query = qparser.getQuery();
 
     BooleanQuery bq = (BooleanQuery) query;
@@ -436,7 +435,7 @@ private SolrQueryRequest createRequest(String query) {
     par.add("rows", "30");
     par.add("fl", "id,score");
     par.remove("qt");
-    SolrParams newp = SolrParams.toSolrParams(par);
+    SolrParams newp = par.toSolrParams();
     qr.setParams(newp);
     return qr;
   }
diff --git a/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java b/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
index 912ee39c27e..0ac7e8de317 100644
--- a/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
+++ b/solr/solrj/src/java/org/apache/solr/common/params/SolrParams.java
@@ -22,12 +22,7 @@
 import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
@@ -435,66 +430,6 @@ public static SolrParams wrapAppended(SolrParams params, SolrParams defaults) {
     return AppendedSolrParams.wrapAppended(params, defaults);
   }
 
-  /** Create a Map&lt;String,String&gt; from a NamedList given no keys are repeated */
-  @Deprecated // Doesn't belong here (no SolrParams).  Just remove.
-  public static Map<String, String> toMap(NamedList<?> params) {
-    HashMap<String, String> map = new HashMap<>();
-    for (int i = 0; i < params.size(); i++) {
-      map.put(params.getName(i), params.getVal(i).toString());
-    }
-    return map;
-  }
-
-  /** Create a Map&lt;String,String[]&gt; from a NamedList */
-  @Deprecated // Doesn't belong here (no SolrParams).  Just remove.
-  public static Map<String, String[]> toMultiMap(NamedList<?> params) {
-    HashMap<String, String[]> map = new HashMap<>();
-    for (int i = 0; i < params.size(); i++) {
-      String name = params.getName(i);
-      Object val = params.getVal(i);
-      if (val instanceof String[]) {
-        MultiMapSolrParams.addParam(name, (String[]) val, map);
-      } else if (val instanceof List) {
-        List<?> l = (List<?>) val;
-        String[] s = new String[l.size()];
-        for (int j = 0; j < l.size(); j++) {
-          s[j] = l.get(j) == null ? null : String.valueOf(l.get(j));
-        }
-        MultiMapSolrParams.addParam(name, s, map);
-      } else {
-        MultiMapSolrParams.addParam(name, val.toString(), map);
-      }
-    }
-    return map;
-  }
-
-  /**
-   * Create SolrParams from NamedList.
-   *
-   * @deprecated Use {@link NamedList#toSolrParams()}.
-   */
-  @Deprecated // move to NamedList to allow easier flow
-  public static SolrParams toSolrParams(NamedList<?> params) {
-    return params.toSolrParams();
-  }
-
-  @Deprecated
-  public SolrParams toFilteredSolrParams(List<String> names) {
-    // TODO do this better somehow via a view that filters?  See SolrCore.preDecorateResponse.
-    //   ... and/or add some optional predicates to iterator()?
-    NamedList<String> nl = new NamedList<>();
-    for (Iterator<String> it = getParameterNamesIterator(); it.hasNext(); ) {
-      final String name = it.next();
-      if (names.contains(name)) {
-        final String[] values = getParams(name);
-        for (String value : values) {
-          nl.add(name, value);
-        }
-      }
-    }
-    return nl.toSolrParams();
-  }
-
   /**
    * Convert this to a NamedList of unique keys with either String or String[] values depending on
    * how many values there are for the parameter.
@@ -515,31 +450,6 @@ public NamedList<Object> toNamedList() {
     return result;
   }
 
-  // Deprecated because there isn't a universal way to deal with multi-values (always
-  //  String[] or only for > 1 or always 1st value).  And what to do with nulls or empty string.
-  //  And SolrParams now implements MapWriter.toMap(Map) (a default method).  So what do we do?
-  @Deprecated
-  public Map<String, Object> getAll(Map<String, Object> sink, Collection<String> params) {
-    if (sink == null) sink = new LinkedHashMap<>();
-    for (String param : params) {
-      String[] v = getParams(param);
-      if (v != null && v.length > 0) {
-        if (v.length == 1) {
-          sink.put(param, v[0]);
-        } else {
-          sink.put(param, v);
-        }
-      }
-    }
-    return sink;
-  }
-
-  /** Copy all params to the given map or if the given map is null create a new one */
-  @Deprecated
-  public Map<String, Object> getAll(Map<String, Object> sink, String... params) {
-    return getAll(sink, params == null ? Collections.emptyList() : Arrays.asList(params));
-  }
-
   /**
    * Returns this SolrParams as a proper URL encoded string, starting with {@code "?"}, if not
    * empty.