2020import com .fasterxml .jackson .databind .node .ObjectNode ;
2121import com .networknt .schema .annotation .JsonNodeAnnotation ;
2222import com .networknt .schema .i18n .DefaultMessageSource ;
23+ import com .networknt .schema .i18n .MessageSource ;
2324
2425import org .slf4j .Logger ;
2526
2930import java .util .Set ;
3031import java .util .function .Consumer ;
3132
33+ /**
34+ * Base {@link JsonValidator}.
35+ */
3236public abstract class BaseJsonValidator extends ValidationMessageHandler implements JsonValidator {
3337 protected final boolean suppressSubSchemaRetrieval ;
3438
3539 protected final JsonNode schemaNode ;
3640
37- protected ValidationContext validationContext ;
41+ protected final ValidationContext validationContext ;
3842
3943 public BaseJsonValidator (SchemaLocation schemaLocation , JsonNodePath evaluationPath , JsonNode schemaNode ,
4044 JsonSchema parentSchema , ValidatorTypeCode validatorType , ValidationContext validationContext ) {
@@ -60,15 +64,41 @@ public BaseJsonValidator(SchemaLocation schemaLocation, JsonNodePath evaluationP
6064 }
6165
6266 /**
63- * Copy constructor.
64- *
65- * @param copy to copy from
67+ * Constructor to create a copy using fields.
68+ *
69+ * @param suppressSubSchemaRetrieval to suppress sub schema retrieval
70+ * @param schemaNode the schema node
71+ * @param validationContext the validation context
72+ * @param errorMessageType the error message type
73+ * @param customErrorMessagesEnabled whether custom error msessages are enabled
74+ * @param messageSource the message source
75+ * @param keyword the keyword
76+ * @param parentSchema the parent schema
77+ * @param schemaLocation the schema location
78+ * @param evaluationPath the evaluation path
79+ * @param evaluationParentSchema the evaluation parent schema
80+ * @param errorMessage the error message
6681 */
67- protected BaseJsonValidator (BaseJsonValidator copy ) {
68- super (copy );
69- this .suppressSubSchemaRetrieval = copy .suppressSubSchemaRetrieval ;
70- this .schemaNode = copy .schemaNode ;
71- this .validationContext = copy .validationContext ;
82+ protected BaseJsonValidator (
83+ /* Below from BaseJsonValidator */
84+ boolean suppressSubSchemaRetrieval ,
85+ JsonNode schemaNode ,
86+ ValidationContext validationContext ,
87+ /* Below from ValidationMessageHandler */
88+ ErrorMessageType errorMessageType ,
89+ boolean customErrorMessagesEnabled ,
90+ MessageSource messageSource ,
91+ Keyword keyword ,
92+ JsonSchema parentSchema ,
93+ SchemaLocation schemaLocation ,
94+ JsonNodePath evaluationPath ,
95+ JsonSchema evaluationParentSchema ,
96+ Map <String , String > errorMessage ) {
97+ super (errorMessageType , customErrorMessagesEnabled , messageSource , keyword ,
98+ parentSchema , schemaLocation , evaluationPath , evaluationParentSchema , errorMessage );
99+ this .suppressSubSchemaRetrieval = suppressSubSchemaRetrieval ;
100+ this .schemaNode = schemaNode ;
101+ this .validationContext = validationContext ;
72102 }
73103
74104 private static JsonSchema obtainSubSchemaNode (final JsonNode schemaNode , final ValidationContext validationContext ) {
0 commit comments