Interface JsonSchemaReaderFactoryBuilder


  • public interface JsonSchemaReaderFactoryBuilder
    A builder interface for building a JsonSchemaReaderFactory instance.

    The following code sample shows how to build a JSON schema reader factory using this interface.

     
     JsonValidationService service = JsonValidationService.newInstance();
     JsonSchemaReaderFactory factory = service.createSchemaReaderFactoryBuilder()
         .withStrictKeywords(true)
         .build();
     
     

    Each instance of this type is NOT safe for use by multiple concurrent threads.

    Author:
    leadpony
    • Method Detail

      • withStrictKeywords

        JsonSchemaReaderFactoryBuilder withStrictKeywords​(boolean strict)
        Specifies whether the schema reader is strict with keywords or not.

        If the reader is strict with keywords, it will report a problem when it encountered an unknown keyword. This value is false by default.

        Parameters:
        strict - true if the schema reader is strict with keywords, false otherwise.
        Returns:
        this builder.
      • withStrictFormats

        JsonSchemaReaderFactoryBuilder withStrictFormats​(boolean strict)
        Specifies whether the schema reader is strict with formats or not.

        If the reader is strict with formats, it will report a problem when it encountered an unknown format attribute. This value is false by default.

        Parameters:
        strict - true if the schema reader is strict with formats, false otherwise.
        Returns:
        this builder.
      • withSchemaResolver

        JsonSchemaReaderFactoryBuilder withSchemaResolver​(JsonSchemaResolver resolver)
        Adds a resolver of external JSON schemas to this builder. Multiple resolvers can be added to a builder.
        Parameters:
        resolver - the resolver of external JSON schemas.
        Returns:
        this builder.
        Throws:
        NullPointerException - if the specified resolver is null.
      • withCustomFormatAttributes

        JsonSchemaReaderFactoryBuilder withCustomFormatAttributes​(boolean enabled)
        Enables or disables the custom format attributes provided through Service Provider Interface. By default, they are enabled.
        Parameters:
        enabled - true to enable the custom format attributes, false to disable them.
        Returns:
        this builder.
      • withDefaultSpecVersion

        JsonSchemaReaderFactoryBuilder withDefaultSpecVersion​(SpecVersion version)
        Specifies the default version of the JSON Schema specification. By default the current version is assigned.
        Parameters:
        version - the default version of the JSON Schema specification.
        Returns:
        this buidler.
        Throws:
        NullPointerException - if the specified version is null.
      • withSchemaValidation

        JsonSchemaReaderFactoryBuilder withSchemaValidation​(boolean enabled)
        Specifies whether the schema reader validates the schema against the metaschema or not. By default, the schema validation is enabled.
        Parameters:
        enabled - true to enable the validation, false to disable the validation.
        Returns:
        this builder.
      • withSpecVersionDetection

        JsonSchemaReaderFactoryBuilder withSpecVersionDetection​(boolean enabled)
        Enables or disables the automatic detection of specification version. By default this option is enabled.
        Parameters:
        enabled - true to enable the detection of specification version, false to disable it.
        Returns:
        this builder.
      • withMetaschema

        JsonSchemaReaderFactoryBuilder withMetaschema​(JsonSchema metaschema)
        Specifies the metaschema to be used when validating the schema.

        By default, the official metaschema provided by JSON Schema specification will be automatically used in accordance with the identifier specified by $schema keyword in the JSON schema.

        Parameters:
        metaschema - the metaschema to be used for validation of the schema.
        Returns:
        this buidler.
        Throws:
        NullPointerException - if the specified metaschema is null.