mengdiwang / guava-libraries

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

Suppliers for Method invocations #518

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A recent Stack Overflow question about wiring Guava Multimaps with Spring 
(http://stackoverflow.com/q/4622821/342852) gave me the idea that it would be 
nice to have factory methods that create method-invoking suppliers.

I would suggest the following two methods:

<K> Supplier<K> Suppliers.forStaticMethodInvocation(Class<?> clazz, String 
methodName, Object ... params);

and

<K> Supplier<K> Suppliers.forBeanMethodInvocation(Object bean, String 
methodName, Object ... params);

That way, Suppliers could be created through Spring XML configuration using 
pretty much any java code.

Attached is my sample code.

Original issue reported on code.google.com by SeanPFl...@googlemail.com on 8 Jan 2011 at 12:03

Attachments:

GoogleCodeExporter commented 9 years ago
Methods like these create holes in the type system; there's zero protection 
against what you call "K" being the completely wrong type.  I don't think these 
are a good fit in Guava.

Original comment by kevinb@google.com on 12 Jan 2011 at 8:35

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