Class YmlSchema.Builder
java.lang.Object
cloud.opencode.base.yml.schema.YmlSchema.Builder
- Enclosing class:
YmlSchema
Builder for constructing YmlSchema instances.
用于构建 YmlSchema 实例的构建器。
- Since:
- JDK 25, opencode-base-yml V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the immutable YmlSchema.Adds a nested schema for validating a sub-document at the given path.Adds a regex pattern constraint for string values at the given path.range(String path, Comparable<?> min, Comparable<?> max) Adds a range constraint for Comparable values at the given path.Adds required keys at the root level.Adds a custom validation rule at the given path.Adds a type constraint: the value at the given path must be assignable to the expected type.
-
Method Details
-
required
Adds required keys at the root level. 在根级别添加必需键。- Parameters:
keys- the required key names | 必需的键名- Returns:
- this builder | 此构建器
-
type
Adds a type constraint: the value at the given path must be assignable to the expected type. 添加类型约束:给定路径处的值必须可赋值给预期类型。- Parameters:
path- the dot-notation path | 点号路径expectedType- the expected type | 预期类型- Returns:
- this builder | 此构建器
-
range
Adds a range constraint for Comparable values at the given path. 为给定路径的 Comparable 值添加范围约束。- Parameters:
path- the dot-notation path | 点号路径min- the minimum value (inclusive), or null for no lower bound | 最小值(含),null 表示无下界max- the maximum value (inclusive), or null for no upper bound | 最大值(含),null 表示无上界- Returns:
- this builder | 此构建器
-
pattern
Adds a regex pattern constraint for string values at the given path. 为给定路径的字符串值添加正则模式约束。- Parameters:
path- the dot-notation path | 点号路径regex- the regex pattern | 正则模式- Returns:
- this builder | 此构建器
- Throws:
PatternSyntaxException- if the regex is invalid | 如果正则无效
-
nested
Adds a nested schema for validating a sub-document at the given path. 添加嵌套模式以验证给定路径处的子文档。- Parameters:
path- the dot-notation path | 点号路径schema- the nested schema | 嵌套模式- Returns:
- this builder | 此构建器
-
rule
Adds a custom validation rule at the given path. 在给定路径添加自定义验证规则。- Parameters:
path- the dot-notation path | 点号路径predicate- the validation predicate | 验证谓词message- the error message if the predicate returns false | 谓词返回 false 时的错误消息- Returns:
- this builder | 此构建器
-
build
-