question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make ImmutableEntry a public type

See original GitHub issue

Because ImmutableEntry is a package-private type Maps.immutableEntry() has to declare its return type as Map.Entry, which (because it’s an interface) can’t be guaranteed to be immutable. This means that users of Maps.immutableEntry() can’t express the immutability of the entry objects they’re constructing to anyone they pass them off to. Since the immutable types are intended to be “‘Interfaces’, not implementations”, I think it would make sense to expose this type publicly.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ben-manescommented, Jun 29, 2017

AbstractMap.SimpleImmutableEntry is built in, so I don’t think this is necessary.

1reaction
cowwoccommented, Mar 6, 2018

@Maaartinus true. I filed a bug report against the JDK. I’ll post the link here once it becomes public.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java - How to create new Entry (key, value) - Stack Overflow
There's public static class AbstractMap. ... a new utility method allowing to create an immutable entry which is Map#entry(Object, Object) .
Read more >
Maps (Guava: Google Core Libraries for Java 23.0 API)
Returns an immutable map instance containing the given entries. Internally, the returned map will be backed by an EnumMap .
Read more >
How to Create a New Entry in a Map - Baeldung
Learn how to use Java's built-in classes, third-party libraries, and a custom implementation to create an Entry object in a Map.
Read more >
Immutable Map in Java - GeeksforGeeks
ImmutableMap, as suggested by the name, is a type of Map which is immutable. It means that the content of the map are...
Read more >
Example usage for com.google.common.collect Maps immutableEntry
@GwtCompatible(serializable = true) public static <K, V> Entry<K, ... Create a MongoDB update object * @param update - the generic specification * @param ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found