I'm fairly pleased with how it's going so far, but I'm struggling to find a nice way to make my ActivityMapper work with GIN.
Here is some example code for my activity mapper
public class MyActivityMapper implements ActivityMapper {
private ClientFactory clientFactory;
@Inject
private Provider<TestActivity> provider;
@Inject
public MyActivityMapper(ClientFactory clientFactory) {
super();
this.clientFactory = clientFactory;
}
@Override
public Activity getActivity(final Place place) {
if (place instanceof TestPlace) {
TestActivity activity = provider.get().withPlace((TestPlace)place);
return activity;
}
return null;
}
}
The provider allows the activity to be injected with the it's various dependencies, including the view, configured in the GinModule. It's all works quite nicely, but the mapper gets a little cumbersome as more and more activities are added to the application.
Does anyone have any suggestions to reduce the amount of "instanceof" boiler plate code?
Many thanks
Tom
-- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/TxNw5a0KCVcJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment