Module org.leadpony.justify
Package org.leadpony.justify.api
Interface JsonSchemaReaderFactoryBuilder
-
public interface JsonSchemaReaderFactoryBuilderA builder interface for building aJsonSchemaReaderFactoryinstance.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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JsonSchemaReaderFactorybuild()Builds a new instance ofJsonSchemaReaderFactory.JsonSchemaReaderFactoryBuilderwithCustomFormatAttributes(boolean enabled)Enables or disables the custom format attributes provided through Service Provider Interface.JsonSchemaReaderFactoryBuilderwithDefaultSpecVersion(SpecVersion version)Specifies the default version of the JSON Schema specification.JsonSchemaReaderFactoryBuilderwithMetaschema(JsonSchema metaschema)Specifies the metaschema to be used when validating the schema.JsonSchemaReaderFactoryBuilderwithSchemaResolver(JsonSchemaResolver resolver)Adds a resolver of external JSON schemas to this builder.JsonSchemaReaderFactoryBuilderwithSchemaValidation(boolean enabled)Specifies whether the schema reader validates the schema against the metaschema or not.JsonSchemaReaderFactoryBuilderwithSpecVersionDetection(boolean enabled)Enables or disables the automatic detection of specification version.JsonSchemaReaderFactoryBuilderwithStrictFormats(boolean strict)Specifies whether the schema reader is strict with formats or not.JsonSchemaReaderFactoryBuilderwithStrictKeywords(boolean strict)Specifies whether the schema reader is strict with keywords or not.
-
-
-
Method Detail
-
build
JsonSchemaReaderFactory build()
Builds a new instance ofJsonSchemaReaderFactory.- Returns:
- newly created instance of
JsonSchemaReaderFactory, never benull.
-
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
falseby default.- Parameters:
strict-trueif the schema reader is strict with keywords,falseotherwise.- 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
falseby default.- Parameters:
strict-trueif the schema reader is strict with formats,falseotherwise.- 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 specifiedresolverisnull.
-
withCustomFormatAttributes
JsonSchemaReaderFactoryBuilder withCustomFormatAttributes(boolean enabled)
Enables or disables the custom format attributes provided through Service Provider Interface. By default, they are enabled.- Parameters:
enabled-trueto enable the custom format attributes,falseto 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 specifiedversionisnull.
-
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-trueto enable the validation,falseto 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-trueto enable the detection of specification version,falseto 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
$schemakeyword in the JSON schema.- Parameters:
metaschema- the metaschema to be used for validation of the schema.- Returns:
- this buidler.
- Throws:
NullPointerException- if the specifiedmetaschemaisnull.
-
-