Class SchemaSetLoader
Utility to load schems set from a JSON stream/file. NOTE:
to avoid adding a new dependency to Curator, the Jackson library has been used
with "provided" scope. You will need to add a dependency to com.fasterxml.jackson.core:jackson-core:2.7.3
and com.fasterxml.jackson.core:jackson-databind:2.7.3
to your project
The JSON stream should be an array of named schemas:
[
{
"name": "name", required - name of the schema
"path": "path or pattern", required - full path or regex pattern
"isRegex": true/false, optional - true if path is a regular expression - default is false
"schemaValidator": "name", optional - name of a schema validator - default is no validator
"documentation": "docs", optional - user displayable docs - default is ""
"ephemeral": "allowance", optional - "can", "must" or "cannot" - default is "can"
"sequential": "allowance", optional - "can", "must" or "cannot" - default is "can"
"watched": "allowance", optional - "can", "must" or "cannot" - default is "can"
"canBeDeleted": true/false optional - true if ZNode at path can be deleted - default is true
"metadata": { optional - any fields -> values that you want
"field1": "value1",
"field2": "value2"
}
}
]
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Called to map a schema validator name in the JSON stream to an actual data validator -
Constructor Summary
ConstructorDescriptionSchemaSetLoader
(com.fasterxml.jackson.databind.JsonNode root, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) SchemaSetLoader
(Reader jsonStream, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) SchemaSetLoader
(String json, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) -
Method Summary
-
Constructor Details
-
SchemaSetLoader
- Parameters:
json
- the json to parseschemaValidatorMapper
- mapper from validator name to instance - can be null if not needed
-
SchemaSetLoader
public SchemaSetLoader(Reader jsonStream, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) - Parameters:
jsonStream
- the json stream to parseschemaValidatorMapper
- mapper from validator name to instance - can be null if not needed
-
SchemaSetLoader
public SchemaSetLoader(com.fasterxml.jackson.databind.JsonNode root, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) - Parameters:
root
- a Jackson root nodeschemaValidatorMapper
- mapper from validator name to instance - can be null if not needed
-
-
Method Details
-
toSchemaSet
- Parameters:
useDefaultSchema
- if true, return a default schema when there is no match. Otherwise, an exception is thrown- Returns:
- schema set
-
getSchemas
-