The bindListener wants a Matcher that either works on TypeLiterals or
Objects (super of TypeLiteral). You're supplying a Matcher that works
on Classes. The compiler wins.;)

I'd make an adapter like this

public static class ClassToTypeLiteralMatcherAdapter extends
AbstractMatcher<TypeLiteral>{
        private final Matcher<Class> classMatcher;

        public ClassToTypeLiteralMatcherAdapter(Matcher<Class>
classMatcher) {
            this.classMatcher = classMatcher;
        }

        public boolean matches(TypeLiteral typeLiteral) {
            return classMatcher.matches(typeLiteral.getRawType());
        }
    }

bindListener(new ClassToTypeLiteralMatcherAdapter(Matchers.subclassesOf
(Foo.class)),...);

or just write a Matcher<TypeLiteral> on the fly.

Cheers,
Alen

On Aug 17, 10:20 pm, Michael Burton <[email protected]> wrote:
> I'm a little confused as to how to use bindListener with a Matcher.
>
> The following works fine:
>
>         bindListener( Matchers.any(), new MyListener() );
>
> However, if I try to limit the matches to a smaller set, I get a
> compilation error:
>
>         bindListener( Matchers.subclassesOf(Foo.class), new MyListener
> () );
>
> "The method bindListener(Matcher<? super TypeLiteral<?>>,
> TypeListener) in the type AbstractModule is not applicable for the
> arguments (Matcher<Class>, MyListener)"
>
> Is there a proper way to limit the set of classes that a listener is
> bound to?
>
> Cheers,
> Mike
--~--~---------~--~----~------------~-------~--~----~
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