vertx-codegen
vertx-codegen copied to clipboard
Abstract data object support in params
Data object params needs to be a plain class because it needs to be reconstructed from Json format (for example in JavaScript or Groovy). This is now not possible because the code generator will not know which data object to create.
We could work around this by having a static method fromJson
returning an instance of that object that would be invoked by the generator, delegating the responsibility of creating the right instance to this method. This method could either use some hard coded mechanism or something else.
For example:
@DataObject
public abstract class AuthOptions {
public static AuthOptions fromJson(JsonObject object) {
...
}
}
This would allow for example the use of a common data object in service proxies or configuration.
resolving this issue would allow to use immutables lib + some tweaks on generation of service proxy with following rule: (if dataobject is interface - use fromJson else if dataobject doesn't have constructor taking JsonObject as param then fallback to fromJson, if none found throw exception)