renatoh commented on code in PR #2932:
URL: https://github.com/apache/solr/pull/2932#discussion_r1911235569
##########
solr/solrj/src/java/org/apache/solr/common/util/SimpleOrderedMap.java:
##########
@@ -67,4 +69,42 @@ public SimpleOrderedMap<T> clone() {
newList.addAll(nvPairs);
return new SimpleOrderedMap<>(newList);
}
+
+ /**
+ * Returns a shared, empty, and immutable instance of SimpleOrderedMap.
+ * @return empty SimpleOrderedMap (immutable)
+ */
+ public static SimpleOrderedMap<Object> of() {
+ return EMPTY;
+ }
+
+ /**
+ * Returns an immutable instance of SimpleOrderedMap with a single element.
+ * @return List containing the elements
+ */
+ public static SimpleOrderedMap<Object> of(Object o1) {
+ return new SimpleOrderedMap<>(List.of(o1));
+ }
+
+ /**
+ * Returns an immutable instance of SimpleOrderedMap with two elements.
+ * @return List containing the elements
+ */
+ public static SimpleOrderedMap<Object> of(Object o1, Object o2) {
Review Comment:
of course, was confused by the fact it internally holds a List t store the
values.
Do you think it still makes sense to have and of for two key-value pairs
e.g. like this:
of(String name1, Object val1, String name2, Object val2)
Looking at Map.of, I think it would also make to use type inference rather
than <Object>, like this:
public static <T> SimpleOrderedMap<T> of(String name, T val)
What do you think?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]