Sorry, I see now I misread your post.  Let me have a re-read.

On Sat, Nov 6, 2010 at 7:12 PM, Fred Faber <[email protected]> wrote:

> Dan,
>
> The problem is that you're trying to create a binding for a class that
> should only be created through its corresponding factory.  This is why you
> see errors when binding your Function class itself.
>
> What is the expectation you have w.r.t. injecting the Function?
>
> -Fred
>
> On Sat, Nov 6, 2010 at 7:07 PM, Dan Billings <[email protected]> wrote:
>
>> I have bound them separately with:
>>
>>
>>
>> bind(TestAssisted.Factory.class).toProvider(FactoryProvider.newFactory(TestAssisted.Factory.class,
>>                        TestAssisted.class));
>>                functionTypeLiteral = new TypeLiteral<Function<String,
>> TestAssisted>>() {
>>                };
>>
>> bind(functionTypeLiteral).to(TestAssisted.Factory.class);
>>
>> but I get the same error.  Whatever process Guice is using to whip up
>> an implementation to the Assisted factory apparently can't handle
>> multiple methods, even if it is equals(Object).
>>
>> But I still want to use Function in the end.  Only the module will
>> know that it is actually pointing to TestAssisted.Factory.
>>
>> On Nov 6, 5:53 pm, Fred Faber <[email protected]> wrote:
>> > 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/co.
>> ..
>> >
>> > > 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]>
>> <google-guice%2bunsubscr...@google groups.com>
>> > > .
>> > > 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]<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.

Reply via email to