-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[FEATURE] Reduce amount of code required to integrate Lombok builders with Jackson #2532
Comments
With @Data
@Jacksonized
@Builder
public class JacksonLombokIntegration {
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private final LocalDateTime day;
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-ddTHH:mm:ss")
private final LocalDateTime time;
}
|
Great idea .. found an issue
|
Please create a new issue for this. |
Sorry - done #2575 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The current recommend way to add Jackson + Lombok builders is to create an interface that the Builder class implements. This can require a simple class to have a
@Builder
, an interface that has serialize annotations, and sometimes duplicated annotations that already exist on the field.It would be nice if a Builder could specify an interface in the annotation, as well as support copying field annotations onto builder setters.
The end result is less boilerplate code that exists only for Lombok, which is actually meant to reduce boilerplate code.
Using a simple POJO with 2 date fields that need to be serialized / deserialized with different formats.
Lombok today:
Desired code:
In this particular example, copying annotations removes the requirement to use an interface at all. Allowing the annotation on an interface reduces the number of times a developer will have to define both an interface, and a builder class.
The text was updated successfully, but these errors were encountered: