I am working on an extension for Vaadin 8. My ServerRPC
interface declares a method which takes in the following (in the shared
package:
public class DomEvent implements Serializable {
public static DomEvent create(final com.google.gwt.event.dom.client.DomEvent<?> gwtEvent) {
return new DomEvent(gwtEvent.getNativeEvent().getType());
}
private final String type;
private final long timeStamp;
private boolean stopPropagation;
public DomEvent(final String type) {
this.type = type;
timeStamp = System.currentTimeMillis();
}
public void stopPropagation() {
stopPropagation = true;
}
public String getType() {
return type;
}
public long getTimeStamp() {
return timeStamp;
}
public boolean shouldStopPropagation() {
return stopPropagation;
}
}
The idea is for my connector to call the create
method. But maybe I misunderstand the required design. This is the compile-time error:
[INFO]
[ERROR]
Errors in 'gen/com/vaadin/client/metadata/ConnectorBundleLoaderImpl.java'
[INFO]
[ERROR]
Line 236: Rebind result 'com.oliveryasuna.vaadin.common.extendedcontrol.shared.event.DomEvent' has no default (zero argument) constructors
So, I tried implementing a default constructor and noticed that it is this constructor which is called during events. Do I really need to implement something like MouseEventDetailsBuilder
? I would prefer the fields that should be final
, be final
.
Thank you all for your time!
EDIT 1:
I did redesign this class to be like that of MouseEventDetails
, being with non-final fields and setters. And I put something like MouseEventDetailsBuilder
in the client
package. This worked. But I would still like to understand why this must be the design. It goes against immutability.