@@ -69,7 +69,7 @@ public class SchemaLoader {
69
69
*/
70
70
@ FunctionalInterface
71
71
private interface CombinedSchemaProvider
72
- extends Function <Collection <Schema >, CombinedSchema .Builder > {
72
+ extends Function <Collection <Schema >, CombinedSchema .Builder > {
73
73
74
74
}
75
75
@@ -138,7 +138,7 @@ public SchemaLoaderBuilder schemaJson(final JSONObject schemaJson) {
138
138
return this ;
139
139
}
140
140
141
- private SchemaLoaderBuilder formatValidators (final Map <String , FormatValidator > formatValidators ) {
141
+ SchemaLoaderBuilder formatValidators (final Map <String , FormatValidator > formatValidators ) {
142
142
this .formatValidators = formatValidators ;
143
143
return this ;
144
144
}
@@ -257,19 +257,19 @@ public SchemaLoader(final SchemaLoaderBuilder builder) {
257
257
258
258
private void addDependencies (final Builder builder , final JSONObject deps ) {
259
259
Arrays .stream (JSONObject .getNames (deps ))
260
- .forEach (ifPresent -> addDependency (builder , ifPresent , deps .get (ifPresent )));
260
+ .forEach (ifPresent -> addDependency (builder , ifPresent , deps .get (ifPresent )));
261
261
}
262
262
263
263
private void addDependency (final Builder builder , final String ifPresent , final Object deps ) {
264
264
typeMultiplexer (deps )
265
- .ifObject ().then (obj -> {
266
- builder .schemaDependency (ifPresent , loadChild (obj ).build ());
267
- })
268
- .ifIs (JSONArray .class ).then (propNames -> {
269
- IntStream .range (0 , propNames .length ())
270
- .mapToObj (i -> propNames .getString (i ))
271
- .forEach (dependency -> builder .propertyDependency (ifPresent , dependency ));
272
- }).requireAny ();
265
+ .ifObject ().then (obj -> {
266
+ builder .schemaDependency (ifPresent , loadChild (obj ).build ());
267
+ })
268
+ .ifIs (JSONArray .class ).then (propNames -> {
269
+ IntStream .range (0 , propNames .length ())
270
+ .mapToObj (i -> propNames .getString (i ))
271
+ .forEach (dependency -> builder .propertyDependency (ifPresent , dependency ));
272
+ }).requireAny ();
273
273
}
274
274
275
275
private void addFormatValidator (final StringSchema .Builder builder , final String formatName ) {
@@ -279,11 +279,11 @@ private void addFormatValidator(final StringSchema.Builder builder, final String
279
279
private void addPropertySchemaDefinition (final String keyOfObj , final Object definition ,
280
280
final ObjectSchema .Builder builder ) {
281
281
typeMultiplexer (definition )
282
- .ifObject ()
283
- .then (obj -> {
284
- builder .addPropertySchema (keyOfObj , loadChild (obj ).build ());
285
- })
286
- .requireAny ();
282
+ .ifObject ()
283
+ .then (obj -> {
284
+ builder .addPropertySchema (keyOfObj , loadChild (obj ).build ());
285
+ })
286
+ .requireAny ();
287
287
}
288
288
289
289
private CombinedSchema .Builder buildAnyOfSchemaForMultipleTypes () {
@@ -306,15 +306,15 @@ private ArraySchema.Builder buildArraySchema() {
306
306
ifPresent ("uniqueItems" , Boolean .class , builder ::uniqueItems );
307
307
if (schemaJson .has ("additionalItems" )) {
308
308
typeMultiplexer ("additionalItems" , schemaJson .get ("additionalItems" ))
309
- .ifIs (Boolean .class ).then (builder ::additionalItems )
310
- .ifObject ().then (jsonObj -> builder .schemaOfAdditionalItems (loadChild (jsonObj ).build ()))
311
- .requireAny ();
309
+ .ifIs (Boolean .class ).then (builder ::additionalItems )
310
+ .ifObject ().then (jsonObj -> builder .schemaOfAdditionalItems (loadChild (jsonObj ).build ()))
311
+ .requireAny ();
312
312
}
313
313
if (schemaJson .has ("items" )) {
314
314
typeMultiplexer ("items" , schemaJson .get ("items" ))
315
- .ifObject ().then (itemSchema -> builder .allItemSchema (loadChild (itemSchema ).build ()))
316
- .ifIs (JSONArray .class ).then (arr -> buildTupleSchema (builder , arr ))
317
- .requireAny ();
315
+ .ifObject ().then (itemSchema -> builder .allItemSchema (loadChild (itemSchema ).build ()))
316
+ .ifIs (JSONArray .class ).then (arr -> buildTupleSchema (builder , arr ))
317
+ .requireAny ();
318
318
}
319
319
return builder ;
320
320
}
@@ -323,8 +323,8 @@ private EnumSchema.Builder buildEnumSchema() {
323
323
Set <Object > possibleValues = new HashSet <>();
324
324
JSONArray arr = schemaJson .getJSONArray ("enum" );
325
325
IntStream .range (0 , arr .length ())
326
- .mapToObj (arr ::get )
327
- .forEach (possibleValues ::add );
326
+ .mapToObj (arr ::get )
327
+ .forEach (possibleValues ::add );
328
328
return EnumSchema .builder ().possibleValues (possibleValues );
329
329
}
330
330
@@ -349,21 +349,21 @@ private ObjectSchema.Builder buildObjectSchema() {
349
349
ifPresent ("maxProperties" , Integer .class , builder ::maxProperties );
350
350
if (schemaJson .has ("properties" )) {
351
351
typeMultiplexer (schemaJson .get ("properties" ))
352
- .ifObject ().then (propertyDefs -> {
353
- populatePropertySchemas (propertyDefs , builder );
354
- }).requireAny ();
352
+ .ifObject ().then (propertyDefs -> {
353
+ populatePropertySchemas (propertyDefs , builder );
354
+ }).requireAny ();
355
355
}
356
356
if (schemaJson .has ("additionalProperties" )) {
357
357
typeMultiplexer ("additionalProperties" , schemaJson .get ("additionalProperties" ))
358
- .ifIs (Boolean .class ).then (builder ::additionalProperties )
359
- .ifObject ().then (def -> builder .schemaOfAdditionalProperties (loadChild (def ).build ()))
360
- .requireAny ();
358
+ .ifIs (Boolean .class ).then (builder ::additionalProperties )
359
+ .ifObject ().then (def -> builder .schemaOfAdditionalProperties (loadChild (def ).build ()))
360
+ .requireAny ();
361
361
}
362
362
if (schemaJson .has ("required" )) {
363
363
JSONArray requiredJson = schemaJson .getJSONArray ("required" );
364
364
IntStream .range (0 , requiredJson .length ())
365
- .mapToObj (requiredJson ::getString )
366
- .forEach (builder ::addRequiredProperty );
365
+ .mapToObj (requiredJson ::getString )
366
+ .forEach (builder ::addRequiredProperty );
367
367
}
368
368
if (schemaJson .has ("patternProperties" )) {
369
369
JSONObject patternPropsJson = schemaJson .getJSONObject ("patternProperties" );
@@ -408,8 +408,8 @@ private StringSchema.Builder buildStringSchema() {
408
408
private void buildTupleSchema (final ArraySchema .Builder builder , final JSONArray itemSchema ) {
409
409
for (int i = 0 ; i < itemSchema .length (); ++i ) {
410
410
typeMultiplexer (itemSchema .get (i ))
411
- .ifObject ().then (schema -> builder .addItemSchema (loadChild (schema ).build ()))
412
- .requireAny ();
411
+ .ifObject ().then (schema -> builder .addItemSchema (loadChild (schema ).build ()))
412
+ .requireAny ();
413
413
}
414
414
}
415
415
@@ -523,16 +523,16 @@ private Schema.Builder<?> lookupReference(final String relPointerString, final J
523
523
}
524
524
JSONPointer pointer = absPointerString .startsWith ("#" )
525
525
? JSONPointer .forDocument (rootSchemaJson , absPointerString )
526
- : JSONPointer .forURL (httpClient , absPointerString );
527
- ReferenceSchema .Builder refBuilder = ReferenceSchema .builder ();
528
- pointerSchemas .put (absPointerString , refBuilder );
529
- QueryResult result = pointer .query ();
530
- JSONObject resultObject = extend (withoutRef (ctx ), result .getQueryResult ());
531
- SchemaLoader childLoader = selfBuilder ().schemaJson (resultObject )
532
- .rootSchemaJson (result .getContainingDocument ()).build ();
533
- Schema referredSchema = childLoader .load ().build ();
534
- refBuilder .build ().setReferredSchema (referredSchema );
535
- return refBuilder ;
526
+ : JSONPointer .forURL (httpClient , absPointerString );
527
+ ReferenceSchema .Builder refBuilder = ReferenceSchema .builder ();
528
+ pointerSchemas .put (absPointerString , refBuilder );
529
+ QueryResult result = pointer .query ();
530
+ JSONObject resultObject = extend (withoutRef (ctx ), result .getQueryResult ());
531
+ SchemaLoader childLoader = selfBuilder ().schemaJson (resultObject )
532
+ .rootSchemaJson (result .getContainingDocument ()).build ();
533
+ Schema referredSchema = childLoader .load ().build ();
534
+ refBuilder .build ().setReferredSchema (referredSchema );
535
+ return refBuilder ;
536
536
}
537
537
538
538
private void populatePropertySchemas (final JSONObject propertyDefs ,
@@ -628,8 +628,8 @@ JSONObject withoutRef(final JSONObject original) {
628
628
}
629
629
JSONObject rval = new JSONObject ();
630
630
Arrays .stream (names )
631
- .filter (name -> !"$ref" .equals (name ))
632
- .forEach (name -> rval .put (name , original .get (name )));
631
+ .filter (name -> !"$ref" .equals (name ))
632
+ .forEach (name -> rval .put (name , original .get (name )));
633
633
return rval ;
634
634
}
635
635
}
0 commit comments