ImmutableMap.ofEntries()
See original GitHub issueCurrently, Immutable.of()
supports only up to 5 key-value pairs. I suggest adding a new method ImmutableMap.ofEntries(Entry<K, V>...)
similar to Map.ofEntries() that appeared in Java 9. This will allow creating ImmutableMap
with any number of key-value pairs.
I also suggest making ImmutableMap.entryOf(K, V)
public so it can be used in ofEntries()
:
ImmutableMap.ofEntries(
ImmutableMap.entryOf("a", 1),
ImmutableMap.entryOf("b", 2));
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
java - What is the use of Map.ofEntries() instead of Map.of()
Returns an immutable Map.Entry containing the given key and value. These entries are suitable for populating Map instances using the Map.
Read more >Java 9 Map.ofEntries() Method - Create Immutable Map ...
In this post, I show you how to create an immutable Map using Java 9 provided Map.ofEntries() static factory method. Create Immutable Map....
Read more >ImmutableMap (Guava: Google Core Libraries for Java 31.1 ...
Returns a new builder, expecting the specified number of entries to be added. void, clear(). Deprecated. Unsupported operation. V ...
Read more >Immutable Map Implementations in Java - Baeldung
Finally, we can use ImmutableMap.of() method to create an immutable map with a set of entries provided on the fly.
Read more >Java Map.of() and Map.ofEntries() Example - ConcretePage.com
ofEntries are the static factory methods of java.util. ... ofEntries() Example ... The unmodifiable Map and immutable Map are not same.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ImmutableMap.ofEntries()
has been added in https://github.com/google/guava/commit/cd3b4197fb523bf26f9122492915006ad306b3f3. It’s now available since Guava 31.In
ImmutableMap.Builder.put()
andImmutableMap.of()
there are also temporaryEntry
objects that are discarded.