@@ -29,23 +29,24 @@ public abstract class BaseJsonValidator implements JsonValidator {
2929 private String schemaPath ;
3030 private JsonNode schemaNode ;
3131 private JsonSchema parentSchema ;
32- private JsonSchema subSchema ;
32+ private boolean suppressSubSchemaRetrieval ;
3333 private ValidatorTypeCode validatorType ;
3434 private ErrorMessageType errorMessageType ;
3535
36+
3637 public BaseJsonValidator (String schemaPath , JsonNode schemaNode , JsonSchema parentSchema ,
3738 ValidatorTypeCode validatorType , ValidationContext validationContext ) {
38- this (schemaPath , schemaNode , parentSchema , validatorType , obainSubSchemaNode ( schemaNode , validationContext ) );
39+ this (schemaPath , schemaNode , parentSchema , validatorType , false );
3940 }
4041
4142 public BaseJsonValidator (String schemaPath , JsonNode schemaNode , JsonSchema parentSchema ,
42- ValidatorTypeCode validatorType , JsonSchema subSchema ) {
43+ ValidatorTypeCode validatorType , boolean suppressSubSchemaRetrieval ) {
4344 this .errorMessageType = validatorType ;
4445 this .schemaPath = schemaPath ;
4546 this .schemaNode = schemaNode ;
4647 this .parentSchema = parentSchema ;
4748 this .validatorType = validatorType ;
48- this .subSchema = subSchema ;
49+ this .suppressSubSchemaRetrieval = suppressSubSchemaRetrieval ;
4950 }
5051
5152 protected String getSchemaPath () {
@@ -60,15 +61,12 @@ protected JsonSchema getParentSchema() {
6061 return parentSchema ;
6162 }
6263
63- protected JsonSchema getSubSchema ( ) {
64- return subSchema ;
64+ protected JsonSchema fetchSubSchemaNode ( ValidationContext validationContext ) {
65+ return suppressSubSchemaRetrieval ? null : obtainSubSchemaNode ( schemaNode , validationContext ) ;
6566 }
6667
67- protected boolean hasSubSchema () {
68- return subSchema != null ;
69- }
7068
71- protected static JsonSchema obainSubSchemaNode (JsonNode schemaNode , ValidationContext validationContext ){
69+ private static JsonSchema obtainSubSchemaNode (JsonNode schemaNode , ValidationContext validationContext ){
7270 JsonNode node = schemaNode .get ("id" );
7371 if (node == null ) return null ;
7472 if (node .equals (schemaNode .get ("$schema" ))) return null ;
0 commit comments