Skip to content

Commit cd245ba

Browse files
committed
Moved duplicate constructor code to init method
1 parent 3f0c4a7 commit cd245ba

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,25 @@ public class JsonSchema extends BaseJsonValidator {
4747
JsonSchema(ObjectMapper mapper, String schemaPath, JsonNode schemaNode,
4848
JsonSchema parent) {
4949
super(schemaPath, schemaNode, parent, null);
50-
this.mapper = mapper;
51-
52-
validators = new LinkedHashMap<String, JsonValidator>();
53-
54-
read(schemaNode);
50+
this.init(mapper, schemaNode);
5551
}
5652

5753
JsonSchema(ObjectMapper mapper, String schemaPath, JsonNode schemaNode,
5854
JsonSchema parent, JsonSchema subSchema) {
5955
super(schemaPath, schemaNode, parent, null, subSchema);
60-
this.mapper = mapper;
61-
62-
validators = new LinkedHashMap<String, JsonValidator>();
63-
64-
read(schemaNode);
56+
this.init(mapper, schemaNode);
6557
}
6658

6759
public JsonSchema(ObjectMapper mapper, JsonNode schemaNode, JsonSchema subSchema) {
6860
this(mapper, "#", schemaNode, null, subSchema);
6961
}
7062

63+
private void init(ObjectMapper mapper, JsonNode schemaNode) {
64+
this.mapper = mapper;
65+
this.validators = new LinkedHashMap<String, JsonValidator>();
66+
this.read(schemaNode);
67+
}
68+
7169
/**
7270
* Find the schema node for $ref attribute.
7371
*

0 commit comments

Comments
 (0)