yangxu998 / guava-libraries

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

problem with creating instances of an ArrayListMultimap #657

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I use this interface in order to keep a short names: 

public interface MyMultimap<T> extends ListMultimap<T,MyClass<T>>{}

the problem is that when I try to create objects declared with my interface it 
seems that it's not possible:

MyMultimap<T> mmm = ArrayListMultimap.create();//don't works

but, with the initial interface obviously it works:

ListMultimap<T, MyClass<T>> lengt1seq = ArrayListMultimap.create();

It's a little weird, can someone give me a hint? 

Thanks,
Adrian B.

Original issue reported on code.google.com by adrianul...@gmail.com on 12 Jul 2011 at 8:43

GoogleCodeExporter commented 9 years ago
ArrayListMultimap implements ListMultimap and does not implement MyMultimap. If 
you want to be able to do something like this, you'll need to do something like 
create an implementation of MyMultimap that extends ForwardingListMultimap and 
then create it using an ArrayListMultimap as the delegate (or make MyMultimap a 
class that extends ForwardingListMultimap itself).

Questions like this should be asked on StackOverflow 
(http://stackoverflow.com/questions/ask) rather than here.

Original comment by cgdec...@gmail.com on 12 Jul 2011 at 12:01

GoogleCodeExporter commented 9 years ago
ok. merci.

Original comment by adrianul...@gmail.com on 12 Jul 2011 at 12:13

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:15

GoogleCodeExporter commented 9 years ago

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