Class SchemaSetLoader

java.lang.Object
org.apache.curator.framework.schema.SchemaSetLoader

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"
         }
     }
 ]
 

  • Constructor Details

    • SchemaSetLoader

      public SchemaSetLoader(String json, SchemaSetLoader.SchemaValidatorMapper schemaValidatorMapper)
      Parameters:
      json - the json to parse
      schemaValidatorMapper - 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 parse
      schemaValidatorMapper - 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 node
      schemaValidatorMapper - mapper from validator name to instance - can be null if not needed
  • Method Details

    • toSchemaSet

      public SchemaSet toSchemaSet(boolean useDefaultSchema)
      Parameters:
      useDefaultSchema - if true, return a default schema when there is no match. Otherwise, an exception is thrown
      Returns:
      schema set
    • getSchemas

      public List<Schema> getSchemas()