I have been working with Activities and Places to develop an application in GWT.
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