Class SpecVersionDetector


  • public final class SpecVersionDetector
    extends java.lang.Object
    This class is used to detect schema version
    Since:
    25/06/20
    • Constructor Detail

      • SpecVersionDetector

        private SpecVersionDetector()
    • 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, throws JsonSchemaException 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 empty Optional value, otherwise - returns the detected spec version wrapped into Optional.
        Parameters:
        jsonNode - JSON Node to read from
        throwIfUnsupported - whether to throw an exception if the version is not supported
        Returns:
        Spec version if present, otherwise empty
      • 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)