It would be awesome if the gwt compiler would support something along these lines:
<replace-with class="com.my.FavoriteImplementation">
<when-type-is class="com.SomeInterface"/>
<set-object-property type="boolean" value="false" name="turnFeatureOn"/>
<set-object-property type="string" value="MyPrimaryStyle" name="defaultStyle"/>
<set-object-property name="complexProperty" provider="com.my.ComplexPropertyProvider"/>
</replace-with>
This might actually reduce the need for custom generators and make customization via GWT.create a bit more powerful.
What about:
public abstract class AbstractImplementation implements SomeInterface {
public AbstractImplementation(boolean turnFeatureOn, String defaultStyle, ComplexProperty complexProperty) {
// store as fields
}
}
public class FavoriteImplementation extends AbstractImplementation {
public FavoriteImplementation() {
super(false, "MyPrimaryStyle", new DefaultComplexProperty);
}
}
public class SometimesDifferentImplementation extends AbstractImplementation {
public FavoriteImplementation() {
super(true, "MySecondaryStyle", new CustomComplexProperty);
}
}
<replace-with class="com.my.FavoriteImplementation">
<when-type-is class="com.SomeInterface"/>
<replace-with class="com.my.SometimesDifferentImplementation">
<when-type-is class="com.SomeInterface"/>
<when-property-is name="sometimes" value="different" />
</replace-with>
-- J.