I've been playing around with this for som time. I can't see a more
reasonable solution than the one Amir and Aigeec proposed.

Sure, the getActivity method with a long list of if-the-else's doesn't
seem nice, but this alternative is just too much boilerplate for my
liking. Lots of Provider classes with the only benefit of avoiding one
ugly method seems to be more trouble than it's worth.

In other words, I gonna stick with the below until something better
comes along:

public class AppActivityMapper implements ActivityMapper {

    private AppGinjector injector;

    @Inject
    public AppActivityMapper(MailGinjector injector) {
        this.injector = injector;
    }

    @Override
    public Activity getActivity(Place place) {
        if (place instanceof HelloPlace) {
            return injector.getHelloActivity().withPlace((HelloPlace)
place);
        }
        else if (place instanceof GoodbyePlace) {
            return
injector.getGoodbyeActivity().withPlace((GoodbyePlace) place);
        }
        return null;
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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-web-toolkit?hl=en.

Reply via email to