Dan, You shouldn't be binding the Function itself; instead, you're expected to bind TestAssisted.Factory, which creates instances of your Function.
-Fred On Sat, Nov 6, 2010 at 6:46 PM, Dan Billings <[email protected]> wrote: > I'm attempting to short-circuit a lot of code by making my Factory > interfaces extend Guava's Function: > > http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Function.html > > public class TestAssisted { > interface Factory extends Function<String, TestAssisted> {} > > @Inject > public TestAssisted(@Assisted String contents){} > } > > I then bind it with: > bind(new TypeLiteral<Function<String,TestAssisted>>() > {}) .toProvider( FactoryProvider.newFactory( > TestAssisted.Factory.class,TestAssisted.class ); > > This seems to be okay, but Guice trips over Function's equal's method: > > No implementation for java.lang.String annotated with > @com.google.inject.assistedinject.Assisted(value=) was bound. > while locating java.lang.String annotated with > @com.google.inject.assistedinject.Assisted(value=) > for parameter 0 at > com.billco.commons.test.TestAssisted.<init>(TestAssisted.java:18) > at com.google.common.base.Function.equals(Function.java:1) > > Do I have any options to have Guice more or less ignore the "equals" > method declared in Function? I can't think of a good way to stick to > interfaces and yet remove the necessity to implement "equals". > > Thanks for your help, > -Dan > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
