lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerlowsk...@apache.org
Subject [3/3] lucene-solr:branch_7x: SOLR-12947: Misc JsonQueryRequest code cleanup
Date Wed, 14 Nov 2018 20:08:36 GMT
SOLR-12947: Misc JsonQueryRequest code cleanup


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6faddfe3
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6faddfe3
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6faddfe3

Branch: refs/heads/branch_7x
Commit: 6faddfe3b411fa5d9e9d06cc599d01a608112ed4
Parents: 3dba71d
Author: Jason Gerlowski <gerlowskija@apache.org>
Authored: Fri Nov 9 13:15:08 2018 -0500
Committer: Jason Gerlowski <gerlowskija@apache.org>
Committed: Wed Nov 14 14:57:53 2018 -0500

----------------------------------------------------------------------
 .../client/solrj/request/json/JsonQueryRequest.java    | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6faddfe3/solr/solrj/src/java/org/apache/solr/client/solrj/request/json/JsonQueryRequest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/json/JsonQueryRequest.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/request/json/JsonQueryRequest.java
index bc79881..781d9c3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/json/JsonQueryRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/json/JsonQueryRequest.java
@@ -191,9 +191,7 @@ public class JsonQueryRequest extends QueryRequest {
     if (filterQuery == null) {
       throw new IllegalArgumentException("'filterQuery' must be non-null");
     }
-    jsonRequestMap.putIfAbsent("filter", new ArrayList<Object>());
-    final List<Object> filters = (List<Object>) jsonRequestMap.get("filter");
-    filters.add(filterQuery);
+    ((List)jsonRequestMap.computeIfAbsent("filter", s -> new ArrayList<>())).add(filterQuery)
;
     return this;
   }
 
@@ -220,9 +218,7 @@ public class JsonQueryRequest extends QueryRequest {
     if (filterQuery == null) {
       throw new IllegalArgumentException("'filterQuery' parameter must be non-null");
     }
-    jsonRequestMap.putIfAbsent("filter", new ArrayList<Object>());
-    final List<Object> filters = (List<Object>) jsonRequestMap.get("filter");
-    filters.add(filterQuery);
+    ((List)jsonRequestMap.computeIfAbsent("filter", s -> new ArrayList<>())).add(filterQuery)
;
     return this;
   }
 
@@ -254,6 +250,7 @@ public class JsonQueryRequest extends QueryRequest {
     if (fieldNames == null) {
       throw new IllegalArgumentException("'fieldNames' parameter must be non-null");
     }
+
     jsonRequestMap.putIfAbsent("fields", new ArrayList<String>());
     final List<String> fields = (List<String>) jsonRequestMap.get("fields");
     for (String fieldName : fieldNames) {
@@ -286,9 +283,7 @@ public class JsonQueryRequest extends QueryRequest {
       throw new IllegalArgumentException("'value' parameter must be non-null");
     }
 
-    jsonRequestMap.putIfAbsent("params", new HashMap<String, Object>());
-    final Map<String, Object> miscParamsMap = (Map<String, Object>) jsonRequestMap.get("params");
-    miscParamsMap.put(name, value);
+    ((Map<String, Object>)jsonRequestMap.computeIfAbsent("params", s -> new HashMap<String,
Object>())).put(name, value);
     return this;
   }
 


Mime
View raw message