StageSource { @JsonCreator public static StageSource create(@JsonProperty("stage") @Min(0) int stage, @JsonProperty("match_all") boolean matchAll, @JsonProperty("rules") List<String> rules) { return builder() .stage(stage) .matchAll(matchAll) .rules(rules) .build(); }  @Min(0) @JsonProperty("stage") abstract int stage(); @JsonProperty("match_all") abstract boolean matchAll(); @JsonProperty("rules") abstract List<String> rules(); @JsonCreator static StageSource create(@JsonProperty("stage") @Min(0) int stage,
                                     @JsonProperty("match_all") boolean matchAll,
                                     @JsonProperty("rules") List<String> rules); static Builder builder(); abstract Builder toBuilder();  }
@Test public void testSerialization() throws Exception { final StageSource stageSource = StageSource.create(23, true, Collections.singletonList("some-rule")); final JsonNode json = objectMapper.convertValue(stageSource, JsonNode.class); assertThat(json.path("stage").asInt()).isEqualTo(23); assertThat(json.path("match_all").asBoolean()).isTrue(); assertThat(json.path("rules").isArray()).isTrue(); assertThat(json.path("rules")).hasSize(1); assertThat(json.path("rules").get(0).asText()).isEqualTo("some-rule"); }