AdjacentSchemaExtractionState { AdjacentSchemaExtractionState reduce(ExtractionResult result) { Set<Schema.Builder<?>> newExtractedSchemas = new HashSet<>(extractedSchemas.size() + result.extractedSchemas.size()); newExtractedSchemas.addAll(extractedSchemas); newExtractedSchemas.addAll(result.extractedSchemas); JsonObject projectedContext = new ProjectedJsonObject(context, result.consumedKeys); return new AdjacentSchemaExtractionState(projectedContext, newExtractedSchemas); } AdjacentSchemaExtractionState(JsonObject context); private  AdjacentSchemaExtractionState(JsonObject context, Set<Schema.Builder<?>> extractedSchemas); JsonObject projectedSchemaJson(); Collection<Schema.Builder<?>> extractedSchemaBuilders();  }
@Test public void testReduce() { AdjacentSchemaExtractionState original = new AdjacentSchemaExtractionState(JsonValue.of(ImmutableMap.builder() .put("const", "2") .put("minimum", 1) .build() ).requireObject()); ConstSchema.ConstSchemaBuilder schemaBuilder = ConstSchema.builder().permittedValue("2"); AdjacentSchemaExtractionState actual = original.reduce(new ExtractionResult("const", asList(schemaBuilder))); assertEquals(singleton(schemaBuilder), actual.extractedSchemaBuilders()); assertEquals(singleton("minimum"), actual.projectedSchemaJson().keySet()); }