GWT PojoBuilder is no longer necessary since GWT support has been enabled in PojoBuilder as of version v4.1.0.
GWT PojoBuilder enables PojoBuilder-generated builders to be used in GWT.
PojoBuilder is a code generator
that generates fluent builder classes for POJOs (Plain Old Java Objects). The
builders it generates include a clone()
method and catch exceptions that
are not included in GWT's JRE emulation.
This project includes an implementation of these and a workaround for the
clone()
override issue.
GWT PojoBuilder is available in Maven Central. To use it, add the following dependency to your POM:
<dependency>
<groupId>com.thamtech.gwt</groupId>
<artifactId>gwt-pojobuilder</artifactId>
<version>${gwt-pojobuilder.version}</version>
</dependency>
(Don't forget to include a separate dependency for PojoBuilder.)
In your GWT module, inherit from com.thamtech.gwt.pojobuilder.PojoBuilder
:
<module>
<inherits name="com.thamtech.gwt.pojobuilder.PojoBuilder"/>
</module>
Set the baseclass of your builder classes to NotCloneableObject
:
import com.thamtech.gwt.pojobuilder.client.NotCloneableObject;
...
@GeneratePojoBuilder(withBaseclass=NotCloneableObject.class)
...
If your use case requires your own base class, you will need to ensure that
some parent of the generated builder implements the clone()
method so that
GWT does not complain when it sees the builder class implement
@Override public Object clone()
.