Skip to content

Commit 9eed0cc

Browse files
committed
Rename JsonSchemaRef to SchemaRef
1 parent 6701880 commit 9eed0cc

File tree

12 files changed

+67
-67
lines changed

12 files changed

+67
-67
lines changed

src/main/java/com/networknt/schema/JsonSchemaRef.java renamed to src/main/java/com/networknt/schema/SchemaRef.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import java.util.function.Supplier;
1919

2020
/**
21-
* Use this object instead a JsonSchema for references.
21+
* Use this object instead a Schema for references.
2222
*/
23-
public class JsonSchemaRef {
23+
public class SchemaRef {
2424

2525
private final Supplier<Schema> schemaSupplier;
2626

27-
public JsonSchemaRef(Supplier<Schema> schema) {
27+
public SchemaRef(Supplier<Schema> schema) {
2828
this.schemaSupplier = schema;
2929
}
3030

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static SchemaRegistryConfig getInstance() {
4545
return Holder.INSTANCE;
4646
}
4747

48-
public static final int DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH = 40;
48+
public static final int DEFAULT_PRELOAD_SCHEMA_REF_MAX_NESTING_DEPTH = 40;
4949

5050
/**
5151
* The execution context customizer that runs by default for all schemas.
@@ -103,12 +103,12 @@ public static SchemaRegistryConfig getInstance() {
103103
/**
104104
* Controls if the schema will automatically be preloaded.
105105
*/
106-
private final boolean preloadJsonSchema;
106+
private final boolean preloadSchema;
107107

108108
/**
109109
* Controls the max depth of the evaluation path to preload when preloading refs.
110110
*/
111-
private final int preloadJsonSchemaRefMaxNestingDepth;
111+
private final int preloadSchemaRefMaxNestingDepth;
112112

113113
/**
114114
* Used to create {@link com.networknt.schema.regex.RegularExpression}.
@@ -141,7 +141,7 @@ protected SchemaRegistryConfig(boolean cacheRefs,
141141
boolean javaSemantics,
142142
Locale locale, boolean losslessNarrowing,
143143
MessageSource messageSource, PathType pathType,
144-
boolean preloadJsonSchema, int preloadJsonSchemaRefMaxNestingDepth,
144+
boolean preloadSchema, int preloadSchemaRefMaxNestingDepth,
145145
RegularExpressionFactory regularExpressionFactory, SchemaIdValidator schemaIdValidator,
146146
Map<String, Boolean> strictness, boolean typeLoose) {
147147
super();
@@ -155,8 +155,8 @@ protected SchemaRegistryConfig(boolean cacheRefs,
155155
this.losslessNarrowing = losslessNarrowing;
156156
this.messageSource = messageSource;
157157
this.pathType = pathType;
158-
this.preloadJsonSchema = preloadJsonSchema;
159-
this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth;
158+
this.preloadSchema = preloadSchema;
159+
this.preloadSchemaRefMaxNestingDepth = preloadSchemaRefMaxNestingDepth;
160160
this.regularExpressionFactory = regularExpressionFactory;
161161
this.schemaIdValidator = schemaIdValidator;
162162
this.strictness = strictness;
@@ -225,8 +225,8 @@ public PathType getPathType() {
225225
*
226226
* @return the max depth to preload
227227
*/
228-
public int getPreloadJsonSchemaRefMaxNestingDepth() {
229-
return preloadJsonSchemaRefMaxNestingDepth;
228+
public int getPreloadSchemaRefMaxNestingDepth() {
229+
return preloadSchemaRefMaxNestingDepth;
230230
}
231231

232232
/**
@@ -282,7 +282,7 @@ public boolean isLosslessNarrowing() {
282282
* @return true if it should be preloaded
283283
*/
284284
public boolean isPreloadJsonSchema() {
285-
return preloadJsonSchema;
285+
return preloadSchema;
286286
}
287287

288288
/**
@@ -350,8 +350,8 @@ public static Builder builder(SchemaRegistryConfig config) {
350350
builder.losslessNarrowing = config.losslessNarrowing;
351351
builder.messageSource = config.messageSource;
352352
builder.pathType = config.pathType;
353-
builder.preloadJsonSchema = config.preloadJsonSchema;
354-
builder.preloadJsonSchemaRefMaxNestingDepth = config.preloadJsonSchemaRefMaxNestingDepth;
353+
builder.preloadSchema = config.preloadSchema;
354+
builder.preloadSchemaRefMaxNestingDepth = config.preloadSchemaRefMaxNestingDepth;
355355
builder.regularExpressionFactory = config.regularExpressionFactory;
356356
builder.schemaIdValidator = config.schemaIdValidator;
357357
builder.strictness = config.strictness;
@@ -383,8 +383,8 @@ public static abstract class BuilderSupport<T> {
383383
protected boolean losslessNarrowing = false;
384384
protected MessageSource messageSource = null;
385385
protected PathType pathType = PathType.JSON_POINTER;
386-
protected boolean preloadJsonSchema = true;
387-
protected int preloadJsonSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_JSON_SCHEMA_REF_MAX_NESTING_DEPTH;
386+
protected boolean preloadSchema = true;
387+
protected int preloadSchemaRefMaxNestingDepth = DEFAULT_PRELOAD_SCHEMA_REF_MAX_NESTING_DEPTH;
388388
protected RegularExpressionFactory regularExpressionFactory = JDKRegularExpressionFactory.getInstance();
389389
protected SchemaIdValidator schemaIdValidator = SchemaIdValidator.DEFAULT;
390390
protected Map<String, Boolean> strictness = new HashMap<>(0);
@@ -515,19 +515,19 @@ public T pathType(PathType pathType) {
515515
* @return the builder
516516
*/
517517
public T preloadJsonSchema(boolean preloadJsonSchema) {
518-
this.preloadJsonSchema = preloadJsonSchema;
518+
this.preloadSchema = preloadJsonSchema;
519519
return self();
520520
}
521521
/**
522522
* Sets the max depth of the evaluation path to preload when preloading refs.
523523
* <p>
524524
* Defaults to 40.
525525
*
526-
* @param preloadJsonSchemaRefMaxNestingDepth to preload
526+
* @param preloadSchemaRefMaxNestingDepth to preload
527527
* @return the builder
528528
*/
529-
public T preloadJsonSchemaRefMaxNestingDepth(int preloadJsonSchemaRefMaxNestingDepth) {
530-
this.preloadJsonSchemaRefMaxNestingDepth = preloadJsonSchemaRefMaxNestingDepth;
529+
public T preloadSchemaRefMaxNestingDepth(int preloadSchemaRefMaxNestingDepth) {
530+
this.preloadSchemaRefMaxNestingDepth = preloadSchemaRefMaxNestingDepth;
531531
return self();
532532
}
533533
/**
@@ -575,7 +575,7 @@ public SchemaRegistryConfig build() {
575575
return new SchemaRegistryConfig(cacheRefs, errorMessageKeyword,
576576
executionContextCustomizer, failFast, formatAssertionsEnabled,
577577
javaSemantics, locale, losslessNarrowing, messageSource,
578-
pathType, preloadJsonSchema, preloadJsonSchemaRefMaxNestingDepth,
578+
pathType, preloadSchema, preloadSchemaRefMaxNestingDepth,
579579
regularExpressionFactory, schemaIdValidator, strictness, typeLoose
580580
);
581581
}

src/main/java/com/networknt/schema/keyword/DynamicRefValidator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.networknt.schema.JsonNodePath;
2525
import com.networknt.schema.Schema;
2626
import com.networknt.schema.JsonSchemaException;
27-
import com.networknt.schema.JsonSchemaRef;
27+
import com.networknt.schema.SchemaRef;
2828
import com.networknt.schema.SchemaLocation;
2929
import com.networknt.schema.SchemaContext;
3030

@@ -34,24 +34,24 @@
3434
* {@link KeywordValidator} that resolves $dynamicRef.
3535
*/
3636
public class DynamicRefValidator extends BaseKeywordValidator {
37-
protected final JsonSchemaRef schema;
37+
protected final SchemaRef schema;
3838

3939
public DynamicRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) {
4040
super(ValidatorTypeCode.DYNAMIC_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath);
4141
String refValue = schemaNode.asText();
4242
this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath);
4343
}
4444

45-
static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue,
45+
static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue,
4646
JsonNodePath evaluationPath) {
4747
String ref = resolve(parentSchema, refValue);
48-
return new JsonSchemaRef(getSupplier(() -> {
48+
return new SchemaRef(getSupplier(() -> {
4949
Schema refSchema = schemaContext.getDynamicAnchors().get(ref);
5050
if (refSchema == null) { // This is a $dynamicRef without a matching $dynamicAnchor
5151
// A $dynamicRef without a matching $dynamicAnchor in the same schema resource
5252
// behaves like a normal $ref to $anchor
5353
// A $dynamicRef without anchor in fragment behaves identical to $ref
54-
JsonSchemaRef r = RefValidator.getRefSchema(parentSchema, schemaContext, refValue, evaluationPath);
54+
SchemaRef r = RefValidator.getRefSchema(parentSchema, schemaContext, refValue, evaluationPath);
5555
if (r != null) {
5656
refSchema = r.getSchema();
5757
}
@@ -140,7 +140,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root
140140
refSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema);
141141
}
142142

143-
public JsonSchemaRef getSchemaRef() {
143+
public SchemaRef getSchemaRef() {
144144
return this.schema;
145145
}
146146

@@ -171,7 +171,7 @@ public void preloadJsonSchema() {
171171
}
172172
}
173173
if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency
174-
&& depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) {
174+
&& depth < this.schemaContext.getSchemaRegistryConfig().getPreloadSchemaRefMaxNestingDepth()) {
175175
jsonSchema.initializeValidators();
176176
}
177177
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import com.networknt.schema.ExecutionContext;
2222
import com.networknt.schema.JsonNodePath;
2323
import com.networknt.schema.Schema;
24-
import com.networknt.schema.JsonSchemaRef;
24+
import com.networknt.schema.SchemaRef;
2525
import com.networknt.schema.SchemaLocation;
2626
import com.networknt.schema.SchemaContext;
2727
import com.networknt.schema.annotation.JsonNodeAnnotation;
28-
import com.networknt.schema.utils.JsonSchemaRefs;
28+
import com.networknt.schema.utils.SchemaRefs;
2929

3030
import java.util.*;
3131

@@ -319,7 +319,7 @@ else if (this.tupleSchema != null) {
319319
private static JsonNode getDefaultNode(Schema schema) {
320320
JsonNode result = schema.getSchemaNode().get("default");
321321
if (result == null) {
322-
JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema);
322+
SchemaRef schemaRef = SchemaRefs.from(schema);
323323
if (schemaRef != null) {
324324
result = getDefaultNode(schemaRef.getSchema());
325325
}

src/main/java/com/networknt/schema/keyword/ItemsValidator202012.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import com.networknt.schema.ExecutionContext;
2222
import com.networknt.schema.JsonNodePath;
2323
import com.networknt.schema.Schema;
24-
import com.networknt.schema.JsonSchemaRef;
24+
import com.networknt.schema.SchemaRef;
2525
import com.networknt.schema.SchemaLocation;
2626
import com.networknt.schema.SchemaContext;
2727
import com.networknt.schema.annotation.JsonNodeAnnotation;
28-
import com.networknt.schema.utils.JsonSchemaRefs;
28+
import com.networknt.schema.utils.SchemaRefs;
2929

3030
/**
3131
* {@link KeywordValidator} for items from V2012-12.
@@ -138,7 +138,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root
138138
private static JsonNode getDefaultNode(Schema schema) {
139139
JsonNode result = schema.getSchemaNode().get("default");
140140
if (result == null) {
141-
JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema);
141+
SchemaRef schemaRef = SchemaRefs.from(schema);
142142
if (schemaRef != null) {
143143
result = getDefaultNode(schemaRef.getSchema());
144144
}

src/main/java/com/networknt/schema/keyword/PrefixItemsValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import com.networknt.schema.ExecutionContext;
2222
import com.networknt.schema.JsonNodePath;
2323
import com.networknt.schema.Schema;
24-
import com.networknt.schema.JsonSchemaRef;
24+
import com.networknt.schema.SchemaRef;
2525
import com.networknt.schema.SchemaLocation;
2626
import com.networknt.schema.SchemaContext;
2727
import com.networknt.schema.annotation.JsonNodeAnnotation;
28-
import com.networknt.schema.utils.JsonSchemaRefs;
28+
import com.networknt.schema.utils.SchemaRefs;
2929

3030
import java.util.ArrayList;
3131
import java.util.List;
@@ -137,7 +137,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root
137137
private static JsonNode getDefaultNode(Schema schema) {
138138
JsonNode result = schema.getSchemaNode().get("default");
139139
if (result == null) {
140-
JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema);
140+
SchemaRef schemaRef = SchemaRefs.from(schema);
141141
if (schemaRef != null) {
142142
result = getDefaultNode(schemaRef.getSchema());
143143
}

src/main/java/com/networknt/schema/keyword/PropertiesValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
import com.networknt.schema.ExecutionContext;
2424
import com.networknt.schema.JsonNodePath;
2525
import com.networknt.schema.Schema;
26-
import com.networknt.schema.JsonSchemaRef;
26+
import com.networknt.schema.SchemaRef;
2727
import com.networknt.schema.SchemaLocation;
2828
import com.networknt.schema.SchemaContext;
2929
import com.networknt.schema.annotation.JsonNodeAnnotation;
30-
import com.networknt.schema.utils.JsonSchemaRefs;
30+
import com.networknt.schema.utils.SchemaRefs;
3131
import com.networknt.schema.walk.WalkListenerRunner;
3232
import java.util.Collections;
3333
import java.util.Iterator;
@@ -153,7 +153,7 @@ private void applyPropertyDefaults(ObjectNode node, ExecutionContext executionCo
153153
private static JsonNode getDefaultNode(Schema schema) {
154154
JsonNode result = schema.getSchemaNode().get("default");
155155
if (result == null) {
156-
JsonSchemaRef schemaRef = JsonSchemaRefs.from(schema);
156+
SchemaRef schemaRef = SchemaRefs.from(schema);
157157
if (schemaRef != null) {
158158
result = getDefaultNode(schemaRef.getSchema());
159159
}

src/main/java/com/networknt/schema/keyword/RecursiveRefValidator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.networknt.schema.JsonNodePath;
2525
import com.networknt.schema.Schema;
2626
import com.networknt.schema.JsonSchemaException;
27-
import com.networknt.schema.JsonSchemaRef;
27+
import com.networknt.schema.SchemaRef;
2828
import com.networknt.schema.SchemaLocation;
2929
import com.networknt.schema.SchemaContext;
3030

@@ -34,7 +34,7 @@
3434
* {@link KeywordValidator} that resolves $recursiveRef.
3535
*/
3636
public class RecursiveRefValidator extends BaseKeywordValidator {
37-
protected final JsonSchemaRef schema;
37+
protected final SchemaRef schema;
3838

3939
public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath, JsonNode schemaNode, Schema parentSchema, SchemaContext schemaContext) {
4040
super(ValidatorTypeCode.RECURSIVE_REF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath);
@@ -51,9 +51,9 @@ public RecursiveRefValidator(SchemaLocation schemaLocation, JsonNodePath evaluat
5151
this.schema = getRefSchema(parentSchema, schemaContext, refValue, evaluationPath);
5252
}
5353

54-
static JsonSchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue,
54+
static SchemaRef getRefSchema(Schema parentSchema, SchemaContext schemaContext, String refValue,
5555
JsonNodePath evaluationPath) {
56-
return new JsonSchemaRef(getSupplier(() -> getSchema(parentSchema, schemaContext, refValue, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs()));
56+
return new SchemaRef(getSupplier(() -> getSchema(parentSchema, schemaContext, refValue, evaluationPath), schemaContext.getSchemaRegistryConfig().isCacheRefs()));
5757
}
5858

5959
static <T> Supplier<T> getSupplier(Supplier<T> supplier, boolean cache) {
@@ -137,7 +137,7 @@ public void walk(ExecutionContext executionContext, JsonNode node, JsonNode root
137137
refSchema.walk(executionContext, node, rootNode, instanceLocation, shouldValidateSchema);
138138
}
139139

140-
public JsonSchemaRef getSchemaRef() {
140+
public SchemaRef getSchemaRef() {
141141
return this.schema;
142142
}
143143

@@ -168,7 +168,7 @@ public void preloadJsonSchema() {
168168
}
169169
}
170170
if (this.schemaContext.getSchemaRegistryConfig().isCacheRefs() && !circularDependency
171-
&& depth < this.schemaContext.getSchemaRegistryConfig().getPreloadJsonSchemaRefMaxNestingDepth()) {
171+
&& depth < this.schemaContext.getSchemaRegistryConfig().getPreloadSchemaRefMaxNestingDepth()) {
172172
jsonSchema.initializeValidators();
173173
}
174174
}

0 commit comments

Comments
 (0)