allalizaki / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
1 stars 0 forks source link

make AbstractMapEntry public #161

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From mailgroup discussion:
http://groups.google.com/group/google-collections-users/browse_thread/thread/8ec
f2ef59a11870e

The release notes for RC1 say

AbstractMapEntry. Most usages of this can be replaced with
java.util.AbstractMap.SimpleEntry/SimpleImmutableEntry provided their keys
and values are directly stored in the Entry instance.

Is there a reason why this was removed, other than being superfluous for
the use cases where you can use the SimpleEntry? I have a use case for
which the entries read through to an array; the entry is essentially just
an index into the array. It would be clean not to have to re-implement
(copy from elsewhere) hashCode and equals.

Thanks,
Joe

Original issue reported on code.google.com by joe.kear...@gtempaccount.com on 7 May 2009 at 1:22

GoogleCodeExporter commented 9 years ago

Original comment by kevin...@gmail.com on 17 Sep 2009 at 5:57

GoogleCodeExporter commented 9 years ago

Original comment by kevin...@gmail.com on 17 Sep 2009 at 6:02

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 30 Jul 2010 at 3:53

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 26 Jan 2011 at 10:41

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 13 Jul 2011 at 6:18

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 10 Dec 2011 at 3:38

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 16 Feb 2012 at 7:17

GoogleCodeExporter commented 9 years ago
I'm not sure I understand how this is still relevant given the existence of 
AbstractMap.SimpleEntry.  Was there something AbstractMapEntry did differently?

Original comment by wasserman.louis on 23 Feb 2012 at 7:38

GoogleCodeExporter commented 9 years ago
As I recall, AbstractMapEntry did not require the key and value to be stored in 
fields in the entry (just declared getters), where 
AbstractMap.Simple[Immutable]Entry does. Not requiring these references allows 
you to pick up the key/value from somewhere else, so that the entry is view 
onto the underlying structure, rather than a part of the structure itself.

Last version of this in Google Collections:
http://code.google.com/p/google-collections/source/browse/trunk/src/com/google/c
ommon/collect/AbstractMapEntry.java

You can obviously just copy into a SimpleImmutableEntry when you need an entry, 
but that won't support write-through of setValue().

Original comment by joe.j.kearney on 24 Feb 2012 at 8:18

GoogleCodeExporter commented 9 years ago
Ew.  I see.

I'm tentatively pro-this, just because I'm pretty confident that our 
AbstractMapEntry implementation will remain fixed -- more confident than, for 
example, Multisets.AbstractEntry -- and that makes me feel like 
AbstractMapEntry might deserve an exception to our general practice of not 
exposing "implementation detail" abstract skeleton classes.

Original comment by wasserman.louis on 24 Feb 2012 at 5:02

GoogleCodeExporter commented 9 years ago
My bias is still to see this as too similar to AbstractMap$SimpleEntry to be 
staking out our own claim to.

Original comment by kevinb@google.com on 24 Feb 2012 at 9:11

GoogleCodeExporter commented 9 years ago
I use a class like this one a lot whenever I wrap a Map like object. For 
example, instead of using HttpSession directly one can use it as an 
Iterable<Map.Entry<String,Object>> which uses an Entry delegating 
getValue/setValue to  the session.

Original comment by daniel.y...@gmail.com on 24 Feb 2012 at 9:59

GoogleCodeExporter commented 9 years ago
I'm convinced by Kevin's argument.  Roll your own if you really need it, for 
the moment.

Original comment by wasserman.louis on 24 Feb 2012 at 10:04

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 30 May 2012 at 7:43

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 22 Jun 2012 at 6:16

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 7 Nov 2013 at 5:29

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:16

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:10