Package com.networknt.schema
Class SpecVersionDetector
- java.lang.Object
-
- com.networknt.schema.SpecVersionDetector
-
public final class SpecVersionDetector extends java.lang.Object
This class is used to detect schema version- Since:
- 25/06/20
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
SCHEMA_TAG
private static java.util.Map<java.lang.String,SpecVersion.VersionFlag>
supportedVersions
-
Constructor Summary
Constructors Modifier Constructor Description private
SpecVersionDetector()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SpecVersion.VersionFlag
detect(com.fasterxml.jackson.databind.JsonNode jsonNode)
Detects schema version based on the schema tag: if the schema tag is not present, throwsJsonSchemaException
with the corresponding message, otherwise - returns the detected spec version.static java.util.Optional<SpecVersion.VersionFlag>
detectOptionalVersion(com.fasterxml.jackson.databind.JsonNode jsonNode, boolean throwIfUnsupported)
Detects schema version based on the schema tag: if the schema tag is not present, returns an emptyOptional
value, otherwise - returns the detected spec version wrapped intoOptional
.static java.util.Optional<SpecVersion.VersionFlag>
detectOptionalVersion(java.lang.String schemaUri)
static SpecVersion.VersionFlag
detectVersion(com.fasterxml.jackson.databind.JsonNode jsonNode, java.nio.file.Path specification, SpecVersion.VersionFlag defaultVersion, boolean throwIfUnsupported)
static java.util.Optional<SpecVersion.VersionFlag>
detectVersionFromPath(java.nio.file.Path path)
-
-
-
Field Detail
-
supportedVersions
private static final java.util.Map<java.lang.String,SpecVersion.VersionFlag> supportedVersions
-
SCHEMA_TAG
private static final java.lang.String SCHEMA_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
detect
public static SpecVersion.VersionFlag detect(com.fasterxml.jackson.databind.JsonNode jsonNode)
Detects schema version based on the schema tag: if the schema tag is not present, throwsJsonSchemaException
with the corresponding message, otherwise - returns the detected spec version.- Parameters:
jsonNode
- JSON Node to read from- Returns:
- Spec version if present, otherwise throws an exception
-
detectOptionalVersion
public static java.util.Optional<SpecVersion.VersionFlag> detectOptionalVersion(com.fasterxml.jackson.databind.JsonNode jsonNode, boolean throwIfUnsupported)
Detects schema version based on the schema tag: if the schema tag is not present, returns an emptyOptional
value, otherwise - returns the detected spec version wrapped intoOptional
.- Parameters:
jsonNode
- JSON Node to read fromthrowIfUnsupported
- whether to throw an exception if the version is not supported- Returns:
- Spec version if present, otherwise empty
-
detectVersion
public static SpecVersion.VersionFlag detectVersion(com.fasterxml.jackson.databind.JsonNode jsonNode, java.nio.file.Path specification, SpecVersion.VersionFlag defaultVersion, boolean throwIfUnsupported)
-
detectVersionFromPath
public static java.util.Optional<SpecVersion.VersionFlag> detectVersionFromPath(java.nio.file.Path path)
-
detectOptionalVersion
public static java.util.Optional<SpecVersion.VersionFlag> detectOptionalVersion(java.lang.String schemaUri)
-
-