-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not compatible with lombok #250
Comments
Did you get any solution for using codegen and lombok both? |
does lombok works with code generators ? |
Hi, With the step-3 in the book (guide-for-java-devs.pdf), and your changes, and some changes, I have an compilation success and the code is generated correctly. My changes are :
Moreover, if I add in the wiki class : package io.vertx.guides.wiki.database;
import io.vertx.codegen.annotations.DataObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@Setter
@AllArgsConstructor
@DataObject(generateConverter = true)
public class Wiki {
public Long id;
public String name;
} After compiling, I have this file generated : //
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package io.vertx.guides.wiki.database;
import io.vertx.core.json.JsonObject;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class WikiConverter {
public WikiConverter() {
}
public static void fromJson(Iterable<Entry<String, Object>> json, Wiki obj) {
Iterator var2 = json.iterator();
while(var2.hasNext()) {
Entry<String, Object> member = (Entry)var2.next();
String var4 = (String)member.getKey();
byte var5 = -1;
switch(var4.hashCode()) {
case 3355:
if (var4.equals("id")) {
var5 = 0;
}
break;
case 3373707:
if (var4.equals("name")) {
var5 = 1;
}
}
switch(var5) {
case 0:
if (member.getValue() instanceof Number) {
obj.setId(((Number)member.getValue()).longValue());
}
break;
case 1:
if (member.getValue() instanceof String) {
obj.setName((String)member.getValue());
}
}
}
}
public static void toJson(Wiki obj, JsonObject json) {
toJson(obj, json.getMap());
}
public static void toJson(Wiki obj, Map<String, Object> json) {
if (obj.getId() != null) {
json.put("id", obj.getId());
}
if (obj.getName() != null) {
json.put("name", obj.getName());
}
}
} |
Thank you @hbayrousson. Adding: |
This is a code example in the book (guide-for-java-devs.pdf), and I made a piece of changes.
Wiki.java
corresponds with the database table:WikiDbService.java
WikiDbServiceImpl.java
Finally, I got a compilation error:
it means that there no suitable constructor for Wiki class with 2 arguments ....
But If I generate the constructor:
It works.
So I think it's not compatible with lombok ...
The text was updated successfully, but these errors were encountered: