From 3a2a61f807eaedd22eab3c6d78653b7de2ae82a4 Mon Sep 17 00:00:00 2001
From: Jan Rieke
+
+ The
+ Without @Jacksonized
was introduced as experimental feature in lombok v1.18.14.
+ @Jacksonized
annotation is an add-on annotation for @Builder
and @SuperBuilder
.
+ It automatically configures the generated builder class to be used by Jackson's deserialization.
+ It only has an effect if present at a context where there is also a @Builder
or a @SuperBuilder
; a warning is emitted otherwise.
+ @Jacksonized
, you would have to customize your builder class(es).
+ With @Jacksonized
, you can simply write something like this to let Jackson use the generated builder:
+@Jacksonized @Builder
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class JacksonExample {
+ private List<Foo> foos;
+}
+
+ This annotation is especially useful when deserializing into immutable (sub-)classes that only use @SuperBuilder
to create instances.
+ With @Jacksonized
, you do not have to put the complex @SuperBuilder
class header into your code just to configure it for Jackson.
+
+ This annotation does not change the behavior of the generated builder.
+ A @Jacksonized
@SuperBuilder
remains fully compatible to regular @SuperBuilder
s.
+
+ In particular, the annotation does the following: +
@JsonDeserialize(builder=Foobar.FoobarBuilder[Impl].class))
on the class (where Foobar is the name of the annotated class).
+ (An error is emitted if such an annotation already exists.)
+ @JsonIgnoreProperties
) from the class to the builder class.
+ This is necessary so that Jackson recognizes them when using the builder.
+ @JsonPOJOBuilder(withPrefix="")
on the generated builder class to override Jackson's default prefix "with".
+ If you configured a different prefix in lombok using setterPrefix
, this value is used.
+ If you changed the name of the build()
method using using buildMethodName
, this is also made known to Jackson.
+ @SuperBuilder
, make the builder implementation class package-private.
+