Class JsonSchemaException.Builder

java.lang.Object
cloud.opencode.base.json.exception.JsonSchemaException.Builder
Enclosing class:
JsonSchemaException

public static class JsonSchemaException.Builder extends Object
Builder for creating exceptions with multiple errors. 用于创建包含多个错误的异常的构建器。
Since:
JDK 25, opencode-base-json V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • schemaUri

      public JsonSchemaException.Builder schemaUri(String schemaUri)
      Sets the schema URI. 设置 Schema URI。
      Parameters:
      schemaUri - the schema URI - Schema URI
      Returns:
      this builder - 此构建器
    • addError

      Adds a validation error. 添加验证错误。
      Parameters:
      error - the validation error - 验证错误
      Returns:
      this builder - 此构建器
    • addError

      public JsonSchemaException.Builder addError(String path, String keyword, String message)
      Adds a validation error with path, keyword, and message. 使用路径、关键字和消息添加验证错误。
      Parameters:
      path - the JSON Pointer path - JSON Pointer 路径
      keyword - the schema keyword - Schema 关键字
      message - the error message - 错误消息
      Returns:
      this builder - 此构建器
    • hasErrors

      public boolean hasErrors()
      Returns whether any errors have been added. 返回是否添加了任何错误。
      Returns:
      true if errors exist - 如果存在错误则返回 true
    • build

      public JsonSchemaException build()
      Builds the exception. 构建异常。
      Returns:
      the exception - 异常
    • throwIfErrors

      public void throwIfErrors() throws JsonSchemaException
      Builds and throws the exception if there are errors. 如果存在错误则构建并抛出异常。
      Throws:
      JsonSchemaException - if there are validation errors - 如果存在验证错误