The following is illegal Java ... so I cannot bind the following in my
AppModule:

        binder.bind(ValueEncoder<Movie>.class,
GenericValueEncoder<Movie>.class);
        binder.bind(ValueEncoder<Video>.class,
GenericValueEncoder<Video>.class);
        binder.bind(ValueEncoder<Book>.class,
GenericValueEncoder<Book>.class);
        binder.bind(ValueEncoder<Song>.class,
GenericValueEncoder<Song>.class);

Instead, I put the following into my AppModule:

        binder.bind(ValueEncoder.class, GenericValueEncoder.class);

Can I safely @Inject this encoder into multiple/different pages?

class MoviePage
{
    @Inject
    private ValueEncoder<Movie> encoder;


class VideoPage
{
    @Inject
    private ValueEncoder<Video> encoder;


If this is safe, although I only bound one instance, does it create a new
instance of the service for each Generic<Parameter> type?



What should happen with something like this:

        binder.bind(AbstractSelectModel.class, GenericSelectModel.class);


when there is no "left-hand" Generic to infer the Generic Parameter from:

class VideoPage
{
    @Inject
    private AbstractSelectModel model;



-Luther

Reply via email to