public class SchemaSetLoader extends Object
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"
}
}
]
Modifier and Type | Class and Description |
---|---|
static interface |
SchemaSetLoader.SchemaValidatorMapper
Called to map a schema validator name in the JSON stream to an actual data validator
|
Constructor and Description |
---|
SchemaSetLoader(com.fasterxml.jackson.databind.JsonNode root,
SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) |
SchemaSetLoader(Reader jsonStream,
SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) |
SchemaSetLoader(String json,
SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper) |
Modifier and Type | Method and Description |
---|---|
List<Schema> |
getSchemas() |
SchemaSet |
toSchemaSet(boolean useDefaultSchema) |
public SchemaSetLoader(String json, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper)
json
- the json to parseschemaValidatorMapper
- mapper from validator name to instance - can be null if not neededpublic SchemaSetLoader(Reader jsonStream, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper)
jsonStream
- the json stream to parseschemaValidatorMapper
- mapper from validator name to instance - can be null if not neededpublic SchemaSetLoader(com.fasterxml.jackson.databind.JsonNode root, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper)
root
- a Jackson root nodeschemaValidatorMapper
- mapper from validator name to instance - can be null if not neededCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.