@@ -29,23 +29,24 @@ public abstract class BaseJsonValidator implements JsonValidator {
29
29
private String schemaPath ;
30
30
private JsonNode schemaNode ;
31
31
private JsonSchema parentSchema ;
32
- private JsonSchema subSchema ;
32
+ private boolean suppressSubSchemaRetrieval ;
33
33
private ValidatorTypeCode validatorType ;
34
34
private ErrorMessageType errorMessageType ;
35
35
36
+
36
37
public BaseJsonValidator (String schemaPath , JsonNode schemaNode , JsonSchema parentSchema ,
37
38
ValidatorTypeCode validatorType , ValidationContext validationContext ) {
38
- this (schemaPath , schemaNode , parentSchema , validatorType , obainSubSchemaNode ( schemaNode , validationContext ) );
39
+ this (schemaPath , schemaNode , parentSchema , validatorType , false );
39
40
}
40
41
41
42
public BaseJsonValidator (String schemaPath , JsonNode schemaNode , JsonSchema parentSchema ,
42
- ValidatorTypeCode validatorType , JsonSchema subSchema ) {
43
+ ValidatorTypeCode validatorType , boolean suppressSubSchemaRetrieval ) {
43
44
this .errorMessageType = validatorType ;
44
45
this .schemaPath = schemaPath ;
45
46
this .schemaNode = schemaNode ;
46
47
this .parentSchema = parentSchema ;
47
48
this .validatorType = validatorType ;
48
- this .subSchema = subSchema ;
49
+ this .suppressSubSchemaRetrieval = suppressSubSchemaRetrieval ;
49
50
}
50
51
51
52
protected String getSchemaPath () {
@@ -60,15 +61,12 @@ protected JsonSchema getParentSchema() {
60
61
return parentSchema ;
61
62
}
62
63
63
- protected JsonSchema getSubSchema ( ) {
64
- return subSchema ;
64
+ protected JsonSchema fetchSubSchemaNode ( ValidationContext validationContext ) {
65
+ return suppressSubSchemaRetrieval ? null : obtainSubSchemaNode ( schemaNode , validationContext ) ;
65
66
}
66
67
67
- protected boolean hasSubSchema () {
68
- return subSchema != null ;
69
- }
70
68
71
- protected static JsonSchema obainSubSchemaNode (JsonNode schemaNode , ValidationContext validationContext ){
69
+ private static JsonSchema obtainSubSchemaNode (JsonNode schemaNode , ValidationContext validationContext ){
72
70
JsonNode node = schemaNode .get ("id" );
73
71
if (node == null ) return null ;
74
72
if (node .equals (schemaNode .get ("$schema" ))) return null ;
0 commit comments