1
1
package org .everit .json .schema .loader ;
2
2
3
- import org .everit .json .schema .ObjectSchema ;
4
- import org .everit .json .schema .Schema ;
5
-
6
3
import static java .util .Objects .requireNonNull ;
7
4
import static org .everit .json .schema .loader .SpecificationVersion .DRAFT_6 ;
8
5
6
+ import org .everit .json .schema .ObjectSchema ;
7
+ import org .everit .json .schema .Schema ;
8
+
9
9
/**
10
10
* @author erosb
11
11
*/
@@ -31,21 +31,21 @@ ObjectSchema.Builder load() {
31
31
.ifPresent (propertyDefs -> populatePropertySchemas (propertyDefs , builder ));
32
32
ls .schemaJson ().maybe ("additionalProperties" ).ifPresent (rawAddProps -> {
33
33
rawAddProps .canBe (Boolean .class , p -> builder .additionalProperties (p ))
34
- .or (JsonObject .class , def -> builder .schemaOfAdditionalProperties (defaultLoader .loadChild (def ).build ()))
35
- .requireAny ();
34
+ .or (JsonObject .class , def -> builder .schemaOfAdditionalProperties (defaultLoader .loadChild (def ).build ()))
35
+ .requireAny ();
36
36
});
37
37
ls .schemaJson ().maybe ("required" ).map (JsonValue ::requireArray )
38
- .ifPresent (arr -> arr .forEach ((i , val ) -> builder .addRequiredProperty (val .requireString ())));
38
+ .ifPresent (arr -> arr .forEach ((i , val ) -> builder .addRequiredProperty (val .requireString ())));
39
39
ls .schemaJson ().maybe ("patternProperties" ).map (JsonValue ::requireObject )
40
- .ifPresent (patternProps -> {
41
- patternProps .keySet ().forEach (pattern -> {
42
- Schema patternSchema = defaultLoader .loadChild (patternProps .require (pattern )).build ();
43
- builder .patternProperty (pattern , patternSchema );
44
- });
45
- });
40
+ .ifPresent (patternProps -> {
41
+ patternProps .keySet ().forEach (pattern -> {
42
+ Schema patternSchema = defaultLoader .loadChild (patternProps .require (pattern )).build ();
43
+ builder .patternProperty (pattern , patternSchema );
44
+ });
45
+ });
46
46
ls .schemaJson ().maybe ("dependencies" ).map (JsonValue ::requireObject )
47
47
.ifPresent (deps -> addDependencies (builder , deps ));
48
- if (DRAFT_6 . equals ( ls .specVersion ())) {
48
+ if (ls .specVersion (). isAtLeast ( DRAFT_6 )) {
49
49
ls .schemaJson ().maybe ("propertyNames" )
50
50
.map (defaultLoader ::loadChild )
51
51
.map (Schema .Builder ::build )
@@ -57,11 +57,11 @@ ObjectSchema.Builder load() {
57
57
private void populatePropertySchemas (JsonObject propertyDefs ,
58
58
ObjectSchema .Builder builder ) {
59
59
propertyDefs .forEach ((key , value ) -> {
60
- if (!key .equals (ls .specVersion ().idKeyword ())
61
- || value instanceof JsonObject ) {
62
- addPropertySchemaDefinition (key , value , builder );
63
- }
64
- });
60
+ if (!key .equals (ls .specVersion ().idKeyword ())
61
+ || value instanceof JsonObject ) {
62
+ addPropertySchemaDefinition (key , value , builder );
63
+ }
64
+ });
65
65
}
66
66
67
67
private void addPropertySchemaDefinition (String keyOfObj , JsonValue definition , ObjectSchema .Builder builder ) {
0 commit comments