-
public interface ValidationConfigA configuration type for configuring JSON validation. The map generated from this configuration can be passed to the methods likeJsonValidationService.createParserFactory(Map)andJsonValidationService.createReaderFactory(Map).Each instance of this type is NOT safe for use by multiple concurrent threads.
- Author:
- leadpony
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_VALUESThe property used to specify whether JSON instances will be filled with default values or not.static StringPROBLEM_HANDLER_FACTORYThe property used to specify the factory of problem handlers.static StringSCHEMAThe property used to specify the JSON schema.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<String,Object>getAsMap()Returns all configuration properties as an unmodifiable map.Optional<Object>getProperty(String name)Returns the value of the specified configuration property.ValidationConfigsetProperty(String name, Object value)Assigns the new value to the specified configuration property.ValidationConfigwithDefaultValues(boolean usingDefaultValues)Specifies whether JSON instances will be filled with default values while being validated or not.ValidationConfigwithProblemHandler(ProblemHandler handler)Specifies the handler of problems detected by the JSON validators.ValidationConfigwithProblemHandlerFactory(ProblemHandlerFactory handlerFactory)Specifies the factory of problem handlers.ValidationConfigwithProperties(Map<String,?> properties)Assigns set of configuration properties.ValidationConfigwithSchema(JsonSchema schema)Specifies the JSON schema used by the validators.
-
-
-
Field Detail
-
DEFAULT_VALUES
static final String DEFAULT_VALUES
The property used to specify whether JSON instances will be filled with default values or not.- See Also:
- Constant Field Values
-
PROBLEM_HANDLER_FACTORY
static final String PROBLEM_HANDLER_FACTORY
The property used to specify the factory of problem handlers.- See Also:
- Constant Field Values
-
SCHEMA
static final String SCHEMA
The property used to specify the JSON schema.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAsMap
Map<String,Object> getAsMap()
Returns all configuration properties as an unmodifiable map.- Returns:
- all configuration properties. This may be empty.
-
getProperty
Optional<Object> getProperty(String name)
Returns the value of the specified configuration property.- Parameters:
name- the name of the property.- Returns:
- The value of the requested property.
- Throws:
NullPointerException- if the specifiednameisnull.
-
setProperty
ValidationConfig setProperty(String name, Object value)
Assigns the new value to the specified configuration property.- Parameters:
name- the name of the property.value- the value of the property.- Returns:
- this builder.
- Throws:
NullPointerException- if the specifiednameisnull.
-
withProperties
ValidationConfig withProperties(Map<String,?> properties)
Assigns set of configuration properties.- Parameters:
properties- the configuration properties to assign, can benull.- Returns:
- this builder.
-
withSchema
ValidationConfig withSchema(JsonSchema schema)
Specifies the JSON schema used by the validators.- Parameters:
schema- the JSON schema.- Returns:
- this builder.
- Throws:
NullPointerException- if the specifiedschemaisnull.
-
withProblemHandler
ValidationConfig withProblemHandler(ProblemHandler handler)
Specifies the handler of problems detected by the JSON validators. This method allows to be used if and only if all parsers and readers can safely share a single problem handler.- Parameters:
handler- the handler of problems, cannot benull.- Returns:
- this builder.
- Throws:
NullPointerException- if the specifiedhandlerisnull.
-
withProblemHandlerFactory
ValidationConfig withProblemHandlerFactory(ProblemHandlerFactory handlerFactory)
Specifies the factory of problem handlers. Problem handlers will be created for each instance ofJsonParserandJsonReader.- Parameters:
handlerFactory- the factory of problem handlers, cannot benull- Returns:
- this builder.
- Throws:
NullPointerException- if the specifiedhandlerFactoryisnull.
-
withDefaultValues
ValidationConfig withDefaultValues(boolean usingDefaultValues)
Specifies whether JSON instances will be filled with default values while being validated or not. The default values are provided bydefaultkeywords in the schema. By default, the default values are ignored and the instances never be modified.- Parameters:
usingDefaultValues-trueto fill the instances with default values provided by the schema.falseto ingore default values.- Returns:
- this builder.
-
-