madrob commented on a change in pull request #169: URL: https://github.com/apache/solr/pull/169#discussion_r651278650
########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/io/Tuple.java ########## @@ -77,38 +77,26 @@ public Tuple() { * A copy constructor. * @param fields map containing keys and values to be copied to this tuple */ - public Tuple(Map<?, ?> fields) { - for (Map.Entry<?, ?> entry : fields.entrySet()) { - put(entry.getKey(), entry.getValue()); - } + public Tuple(Map<String, ?> fields) { + this.fields.putAll(fields); + EOF = this.fields.containsKey(StreamParams.EOF); + EXCEPTION = this.fields.containsKey(StreamParams.EXCEPTION); } - /** - * Constructor that accepts an even number of arguments as key / value pairs. - * @param fields a list of key / value pairs, with keys at odd and values at - * even positions. - */ - public Tuple(Object... fields) { - if (fields == null) { - return; - } - if ((fields.length % 2) != 0) { - throw new RuntimeException("must have a matching number of key-value pairs"); - } - for (int i = 0; i < fields.length; i += 2) { - // skip empty entries - if (fields[i] == null) { - continue; - } - put(fields[i], fields[i + 1]); - } + public Tuple(String k1, Object v1) { + if (k1 != null) put(k1, v1); + } + + public Tuple(String k1, Object v1, String k2, Object v2) { + if (k1 != null) put(k1, v1); + if (k2 != null) put(k2, v2); } public Object get(Object key) { Review comment: That one's a little more convoluted because the get and remove and containsKey methods on `Map` take an Object not a generic `K`. Historically this was done for backwards compatibility for something like taking the intersection of a map with Long keys and one with Integer keys for example, which ended up being very hard to do otherwise. That said, Strings are strings, so we could probably change all of the Tuple methods to be safer that way. -- 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. 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