I'm generating pojo using jsonschema2pojo maven plugin. Using custom annotator, I'm including some lombok annotations (which works fine) but it also creates variables for annotations. Is there a way to force jsonschema2pojo to not create object variables for annotation and simply just have variables?
json schema
{
"title": "Person",
"type": "object",
"properties": {
"lombok-builder": true,
"lombok-data": true,
"lombok-to-string": true,
"name": {
"type": "string"
}
}
}
custom annotator
@Override
public void propertyField(JFieldVar field, JDefinedClass clazz, String property, JsonNode propertyNode) {
super.propertyField(field, clazz, property, propertyNode);
if (property.equals("lombok-builder")) {
clazz.annotate(Builder.class);
} else if (property.equals("lombok-data")) {
clazz.annotate(Data.class);
} else if (property.equals("lombok-to-string")) {
clazz.annotate(ToString.class);
}
}
Person.java generated by jsonschema2pojo
package com.package;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
* Person
* <p>
*
*
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@Builder
@Getter
@Setter
@Data
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
@ToString
@JsonPropertyOrder({
"lombok-builder",
"lombok-getter",
"lombok-setter",
"lombok-data",
"lombok-equals-and-hash-code",
"lombok-no-args-constructor",
"lombok-all-args-constructor",
"lombok-to-string",
"name"
})
public class Person {
@JsonProperty("lombok-builder")
public Object lombokBuilder;
@JsonProperty("lombok-data")
public Object lombokData;
@JsonProperty("lombok-to-string")
public Object lombokToString;
@JsonProperty("name")
public String name;
}
As you can see the annotations work fine but I'm getting public Object lombokToString;
, @JsonProperty("lombok-to-string")
etc. :|