Source:
ObjectSchema.Builder load() { ObjectSchema.Builder builder = ObjectSchema.builder(); ls.schemaJson().maybe("minProperties").map(JsonValue::requireInteger).ifPresent(builder::minProperties); ls.schemaJson().maybe("maxProperties").map(JsonValue::requireInteger).ifPresent(builder::maxProperties); ls.schemaJson().maybe("properties").map(JsonValue::requireObject) .ifPresent(propertyDefs -> populatePropertySchemas(propertyDefs, builder)); ls.schemaJson().maybe("additionalProperties").ifPresent(rawAddProps -> { rawAddProps.canBe(Boolean.class, p -> builder.additionalProperties(p)) .or(JsonObject.class, def -> builder.schemaOfAdditionalProperties(defaultLoader.loadChild(def).build())) .requireAny(); }); ls.schemaJson().maybe("required").map(JsonValue::requireArray) .ifPresent(arr -> arr.forEach((i, val) -> builder.addRequiredProperty(val.requireString()))); ls.schemaJson().maybe("patternProperties").map(JsonValue::requireObject) .ifPresent(patternProps -> { patternProps.keySet().forEach(pattern -> { Schema patternSchema = defaultLoader.loadChild(patternProps.require(pattern)).build(); Regexp regexp = ls.config.regexpFactory.createHandler(pattern); builder.patternProperty(regexp, patternSchema); }); }); if (ls.specVersion().isAtLeast(DRAFT_201909)) { ls.schemaJson().maybe("dependentRequired").map(JsonValue::requireObject) .ifPresent(deps -> addDependencies(builder, deps)); } else { ls.schemaJson().maybe("dependencies").map(JsonValue::requireObject) .ifPresent(deps -> addDependencies(builder, deps)); } if (ls.specVersion().isAtLeast(DRAFT_6)) { ls.schemaJson().maybe("propertyNames") .map(defaultLoader::loadChild) .map(Schema.Builder::build) .ifPresent(builder::propertyNameSchema); } return builder; }

Target:
ObjectSchema.Builder load() { ObjectSchema.Builder builder = ObjectSchema.builder(); ls.schemaJson().maybe("minProperties").map(JsonValue::requireInteger).ifPresent(builder::minProperties); ls.schemaJson().maybe("maxProperties").map(JsonValue::requireInteger).ifPresent(builder::maxProperties); ls.schemaJson().maybe("properties").map(JsonValue::requireObject) .ifPresent(propertyDefs -> populatePropertySchemas(propertyDefs, builder)); ls.schemaJson().maybe("additionalProperties").ifPresent(rawAddProps -> { rawAddProps.canBe(Boolean.class, p -> builder.additionalProperties(p)) .or(JsonObject.class, def -> builder.schemaOfAdditionalProperties(defaultLoader.loadChild(def).build())) .requireAny(); }); ls.schemaJson().maybe("required").map(JsonValue::requireArray) .ifPresent(arr -> arr.forEach((i, val) -> builder.addRequiredProperty(val.requireString()))); ls.schemaJson().maybe("patternProperties").map(JsonValue::requireObject) .ifPresent(patternProps -> { patternProps.keySet().forEach(pattern -> { Schema patternSchema = defaultLoader.loadChild(patternProps.require(pattern)).build(); Regexp regexp = ls.config.regexpFactory.createHandler(pattern); builder.patternProperty(regexp, patternSchema); }); }); ls.schemaJson().maybe(ls.specVersion().dependentRequiredKeyword()).map(JsonValue::requireObject) .ifPresent(deps -> addDependencies(builder, deps)); if (ls.specVersion().isAtLeast(DRAFT_6)) { ls.schemaJson().maybe("propertyNames") .map(defaultLoader::loadChild) .map(Schema.Builder::build) .ifPresent(builder::propertyNameSchema); } return builder; }