Skip to content

Commit a47f34f

Browse files
Changes for walk listener
1 parent f5903a4 commit a47f34f

File tree

6 files changed

+202
-175
lines changed

6 files changed

+202
-175
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public class ItemsValidator extends BaseJsonValidator implements JsonValidator {
3434
public ItemsValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema, ValidationContext validationContext) {
3535
super(schemaPath, schemaNode, parentSchema, ValidatorTypeCode.ITEMS, validationContext);
3636
if (schemaNode.isObject() || schemaNode.isBoolean()) {
37-
schema = new JsonSchema(validationContext, getValidatorType().getValue(), parentSchema.getCurrentUri(), schemaNode, parentSchema)
37+
schema = new JsonSchema(validationContext, schemaPath, parentSchema.getCurrentUri(), schemaNode, parentSchema)
3838
.initialize();
3939
} else {
4040
tupleSchema = new ArrayList<JsonSchema>();
4141
for (JsonNode s : schemaNode) {
42-
tupleSchema.add(new JsonSchema(validationContext, getValidatorType().getValue(), parentSchema.getCurrentUri(), s, parentSchema)
42+
tupleSchema.add(new JsonSchema(validationContext, schemaPath, parentSchema.getCurrentUri(), s, parentSchema)
4343
.initialize());
4444
}
4545

src/main/java/com/networknt/schema/walk/AbstractWalkListenerRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected boolean runPreWalkListeners(List<WalkListener> walkListeners, WalkEven
2626
boolean continueRunningListenersAndWalk = true;
2727
if (walkListeners != null) {
2828
for (WalkListener walkListener : walkListeners) {
29-
if (!walkListener.onWalkStart(walkEvent)) {
29+
if (WalkMethodInvocation.SKIP_WALK.equals(walkListener.onWalkStart(walkEvent))) {
3030
continueRunningListenersAndWalk = false;
3131
break;
3232
}

src/main/java/com/networknt/schema/walk/WalkEvent.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,49 +54,49 @@ public JsonSchema getRefSchema(URI schemaUri) {
5454
return currentJsonSchemaFactory.getSchema(schemaUri);
5555
}
5656

57-
static class KeywordWalkEventBuilder {
57+
static class WalkEventBuilder {
5858
private WalkEvent keywordWalkEvent = null;
5959

60-
KeywordWalkEventBuilder() {
60+
WalkEventBuilder() {
6161
keywordWalkEvent = new WalkEvent();
6262
}
6363

64-
public KeywordWalkEventBuilder schemaPath(String schemaPath) {
64+
public WalkEventBuilder schemaPath(String schemaPath) {
6565
keywordWalkEvent.schemaPath = schemaPath;
6666
return this;
6767
}
6868

69-
public KeywordWalkEventBuilder schemaNode(JsonNode schemaNode) {
69+
public WalkEventBuilder schemaNode(JsonNode schemaNode) {
7070
keywordWalkEvent.schemaNode = schemaNode;
7171
return this;
7272
}
7373

74-
public KeywordWalkEventBuilder parentSchema(JsonSchema parentSchema) {
74+
public WalkEventBuilder parentSchema(JsonSchema parentSchema) {
7575
keywordWalkEvent.parentSchema = parentSchema;
7676
return this;
7777
}
7878

79-
public KeywordWalkEventBuilder keyWordName(String keyWordName) {
79+
public WalkEventBuilder keyWordName(String keyWordName) {
8080
keywordWalkEvent.keyWordName = keyWordName;
8181
return this;
8282
}
8383

84-
public KeywordWalkEventBuilder node(JsonNode node) {
84+
public WalkEventBuilder node(JsonNode node) {
8585
keywordWalkEvent.node = node;
8686
return this;
8787
}
8888

89-
public KeywordWalkEventBuilder rootNode(JsonNode rootNode) {
89+
public WalkEventBuilder rootNode(JsonNode rootNode) {
9090
keywordWalkEvent.rootNode = rootNode;
9191
return this;
9292
}
9393

94-
public KeywordWalkEventBuilder at(String at) {
94+
public WalkEventBuilder at(String at) {
9595
keywordWalkEvent.at = at;
9696
return this;
9797
}
9898

99-
public KeywordWalkEventBuilder currentJsonSchemaFactory(JsonSchemaFactory currentJsonSchemaFactory) {
99+
public WalkEventBuilder currentJsonSchemaFactory(JsonSchemaFactory currentJsonSchemaFactory) {
100100
keywordWalkEvent.currentJsonSchemaFactory = currentJsonSchemaFactory;
101101
return this;
102102
}
@@ -107,8 +107,8 @@ public WalkEvent build() {
107107

108108
}
109109

110-
public static KeywordWalkEventBuilder builder() {
111-
return new KeywordWalkEventBuilder();
110+
public static WalkEventBuilder builder() {
111+
return new WalkEventBuilder();
112112
}
113113

114114
}

src/main/java/com/networknt/schema/walk/WalkListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
public interface WalkListener {
1313

14-
public boolean onWalkStart(WalkEvent walkEvent);
14+
public WalkMethodInvocation onWalkStart(WalkEvent walkEvent);
1515

1616
public void onWalkEnd(WalkEvent walkEvent, Set<ValidationMessage> validationMessages);
1717
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.networknt.schema.walk;
2+
3+
public enum WalkMethodInvocation {
4+
5+
SKIP_WALK("SkipWalk", "Skip the walk methods"),
6+
7+
CONTINUE_TO_WALK("ContinueToWalk", "continue to invoke the walk method");
8+
9+
private String name;
10+
11+
private String description;
12+
13+
WalkMethodInvocation(String name, String description) {
14+
this.name = name;
15+
this.description = description;
16+
}
17+
18+
public String getName() {
19+
return this.name;
20+
}
21+
22+
public String getDescription() {
23+
return this.description;
24+
}
25+
26+
}

0 commit comments

Comments
 (0)