Class SpecError

java.lang.Object
jsonvalues.spec.SpecError

public final class SpecError extends Object
The `SpecError` class represents a code that occurs during the validation of a JSON value against a specification. It encapsulates information about the code, including the path where the code occurred, the code, and the value that triggered the code.

json-values and json-specs in particular, uses `SpecError` instances to report validation errors when a JSON value does not conform to the specified rules and constraints.

Instances of this class are immutable and provide methods for creating and working with validation errors.

The `SpecError` class offers the following key functionality: - Generating a human-readable string representation of the code for debugging and logging purposes. - Implementing equality and hash code methods to compare code instances.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final JsError
    The code indicating the type of validation code.
    final JsPath
    The path where the code occurred within the JSON structure.
    The JSON value that triggered the code.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks whether this `SpecError` instance is equal to another object.
    int
    Computes the hash code of this `SpecError` instance.
    void
     
    Returns a human-readable string representation of the `SpecError` instance.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • path

      public final JsPath path
      The path where the code occurred within the JSON structure.
    • error

      public final JsError error
      The code indicating the type of validation code.
    • spec

      public String spec
      The JSON value that triggered the code.
  • Method Details

    • setSpec

      public void setSpec(String spec)
    • toString

      public String toString()
      Returns a human-readable string representation of the `SpecError` instance.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the code, including path, code, and value.
    • equals

      public boolean equals(Object o)
      Checks whether this `SpecError` instance is equal to another object.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare to this `SpecError`.
      Returns:
      `true` if the objects are equal, `false` otherwise.
    • hashCode

      public int hashCode()
      Computes the hash code of this `SpecError` instance.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code of the code instance based on its components.