Skip to content

Commit 58947aa

Browse files
DaNizz97Daniil Nizovkin
andauthored
JsonValidator: mark preloadJsonSchema as default (networknt#445)
JsonValidator#preloadJsonSchema is not required so there is no point in forcing it to be implemented in each validator. Co-authored-by: Daniil Nizovkin <[email protected]>
1 parent 6a2255f commit 58947aa

File tree

7 files changed

+3
-36
lines changed

7 files changed

+3
-36
lines changed

src/main/java/com/networknt/schema/BaseJsonValidator.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ public Set<ValidationMessage> walk(JsonNode node, JsonNode rootNode, String at,
161161
return validationMessages;
162162
}
163163

164-
@Override
165-
public void preloadJsonSchema() {
166-
// do nothing by default - to be overridden in subclasses
167-
}
168-
169164
protected void preloadJsonSchemas(final Collection<JsonSchema> schemas) {
170165
for (final JsonSchema schema: schemas) {
171166
schema.initializeValidators();

src/main/java/com/networknt/schema/JsonValidator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,7 @@ public interface JsonValidator extends JsonSchemaWalker {
5656
* are invalid (like <code>$ref</code> not resolving)
5757
* @since 1.0.54
5858
*/
59-
void preloadJsonSchema() throws JsonSchemaException;
59+
default void preloadJsonSchema() throws JsonSchemaException {
60+
// do nothing by default - to be overridden in subclasses
61+
}
6062
}

src/main/java/com/networknt/schema/NonValidationKeyword.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ private Validator(String keyword) {
3535
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
3636
return Collections.emptySet();
3737
}
38-
39-
@Override
40-
public void preloadJsonSchema() {
41-
// not used and the Validator is not extending from BaseJsonValidator
42-
}
4338
}
4439

4540
public NonValidationKeyword(String keyword) {

src/main/java/com/networknt/schema/PatternValidator.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,4 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
164164
return Collections.emptySet();
165165
}
166166
}
167-
168-
@Override
169-
public void preloadJsonSchema() {
170-
// not used and the validator does not inherit from BaseJsonValidator
171-
}
172167
}

src/test/java/com/networknt/schema/CollectorContextTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,6 @@ public Set<ValidationMessage> walk(JsonNode node, JsonNode rootNode, String at,
296296
// Ignore this method for testing.
297297
return null;
298298
}
299-
300-
@Override
301-
public void preloadJsonSchema() {
302-
// not used in testing
303-
}
304299
}
305300

306301
private class CustomCollector extends AbstractCollector<List<String>> {
@@ -378,11 +373,6 @@ public Set<ValidationMessage> walk(JsonNode node, JsonNode rootNode, String at,
378373
// Ignore this method for testing.
379374
return null;
380375
}
381-
382-
@Override
383-
public void preloadJsonSchema() {
384-
// not used in testing
385-
}
386376
}
387377

388378
private ValidationResult validate(String jsonData) throws JsonMappingException, JsonProcessingException, Exception {

src/test/java/com/networknt/schema/CustomMetaSchemaTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
6666
String valueName = enumNames.get(idx);
6767
return fail(CustomErrorMessageType.of("tests.example.enumNames", new MessageFormat("{0}: enumName is {1}")), at, valueName);
6868
}
69-
70-
@Override
71-
public void preloadJsonSchema() {
72-
// not used in testing
73-
}
7469
}
7570

7671

src/test/java/com/networknt/schema/JsonWalkTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,6 @@ public Set<ValidationMessage> walk(JsonNode node, JsonNode rootNode, String at,
164164
boolean shouldValidateSchema) {
165165
return new LinkedHashSet<ValidationMessage>();
166166
}
167-
168-
@Override
169-
public void preloadJsonSchema() {
170-
// not used in testing
171-
}
172167
}
173168
}
174169

0 commit comments

Comments
 (0)