Class JsonSchemaException.Builder
java.lang.Object
cloud.opencode.base.json.exception.JsonSchemaException.Builder
- Enclosing class:
JsonSchemaException
Builder for creating exceptions with multiple errors.
用于创建包含多个错误的异常的构建器。
- Since:
- JDK 25, opencode-base-json V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a validation error.Adds a validation error with path, keyword, and message.build()Builds the exception.booleanReturns whether any errors have been added.Sets the schema URI.voidBuilds and throws the exception if there are errors.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
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
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
-
throwIfErrors
Builds and throws the exception if there are errors. 如果存在错误则构建并抛出异常。- Throws:
JsonSchemaException- if there are validation errors - 如果存在验证错误
-