Immutable Lombok annotated class with Jackson

后端 未结 9 2203
再見小時候
再見小時候 2020-12-25 13:02

What is the preferred way to create class that is

  • Immutable
  • Can be serialized/deserialized with Jackson
  • Human-readable and with low level of
9条回答
  •  伪装坚强ぢ
    2020-12-25 13:47

    I've just solved it using this way:

    @Value
    @Builder(setterPrefix = "with")
    @JsonDeserialize(builder = Clazz.ClazzBuilder.class)
    public class Clazz {
        private String field;
    }
    

    In that case, you have to use the builder methods like withField(...), which is the default behaviour used by jackson.

提交回复
热议问题