vertx-codegen
vertx-codegen copied to clipboard
DataObject: Generate a converter for java records
Hi,
This issue proposes to support java16 records with @DataObject generator. Atm generated converter @DataObject for java16 records is empty.
@DataObject(generateConverter = true)
public record Page(int limit, int skip) {
public Page(JsonObject json) {}
public JsonObject toJson() {}
}
as we will soon support Java 17, I guess we could have some code doing this using multi version jar ?
I'm not assigning a version for now
Hi, is it possible to make constructor and toJson() methods as optional? If anyone wants to override default serialization/deserialization they could define custom conversion logic. Now for simple data objects it is required to write all repetitive and error prone conversions
Any update on this @vietj?
not yet @thced
is help still needed with this ? id be willing to help out if someone can point me in the right direction as to where the changes are needed in order to support records... @vietj
I can see that we might need to add the record element kind right here
public boolean process() { if (!processed) { if (modelElt.getKind() == ElementKind.INTERFACE || modelElt.getKind() == ElementKind.CLASS) {
and prob some more stuff in pom to support ElemenKind.RECORD
Is there any change this will worked on soon? Would you accept a PR for this?
I think the main issue is that records are only available in Java 14 and vertx 4 depends on Java 8, we could try suppporting it as a separate project that would be java 14 exclusive
I think the main issue is that records are only available in Java 14 and vertx 4 depends on Java 8, we could try suppporting it as a separate project that would be java 14 exclusive
What do you think about the branch 5.x to be java 17+ compatible instead of 11?
@vietj are there any further developments on java upgrade?
nothing has changed, perhaps we can try to have something compatible with data objects as well using tricks and testing with the right java version, I don't know the amount of changes that would be needed for that