Class ValidationResult

java.lang.Object
cloud.opencode.base.graph.validation.ValidationResult

public final class ValidationResult extends Object
Validation Result 验证结果

Represents the result of graph validation.

表示图验证的结果。

Features | 特性:

  • Collects warnings and errors | 收集警告和错误
  • Provides validation status | 提供验证状态
  • Immutable result structure | 不可变的结果结构

Usage Examples | 使用示例:

ValidationResult result = GraphValidator.validateGraph(graph);
if (result.hasErrors()) {
    result.errors().forEach(System.err::println);
}
if (result.hasWarnings()) {
    result.warnings().forEach(System.out::println);
}

Security | 安全性:

  • Thread-safe: Yes (immutable after construction) - 线程安全: 是(构造后不可变)
  • Null-safe: Yes (stores unmodifiable lists) - 空值安全: 是(存储不可修改的列表)
Since:
JDK 25, opencode-base-graph V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • ValidationResult

      public ValidationResult(List<String> warnings, List<String> errors)
      Create a validation result 创建验证结果
      Parameters:
      warnings - list of warnings | 警告列表
      errors - list of errors | 错误列表
  • Method Details

    • success

      public static ValidationResult success()
      Create a successful validation result 创建成功的验证结果
      Returns:
      a successful validation result | 成功的验证结果
    • error

      public static ValidationResult error(String error)
      Create a validation result with a single error 创建带单个错误的验证结果
      Parameters:
      error - the error message | 错误消息
      Returns:
      a validation result with the error | 带错误的验证结果
    • warning

      public static ValidationResult warning(String warning)
      Create a validation result with a single warning 创建带单个警告的验证结果
      Parameters:
      warning - the warning message | 警告消息
      Returns:
      a validation result with the warning | 带警告的验证结果
    • warnings

      public List<String> warnings()
      Get the list of warnings 获取警告列表
      Returns:
      list of warnings | 警告列表
    • errors

      public List<String> errors()
      Get the list of errors 获取错误列表
      Returns:
      list of errors | 错误列表
    • isValid

      public boolean isValid()
      Check if validation passed (no errors) 检查验证是否通过(无错误)
      Returns:
      true if valid | 如果有效返回true
    • hasErrors

      public boolean hasErrors()
      Check if there are errors 检查是否有错误
      Returns:
      true if there are errors | 如果有错误返回true
    • hasWarnings

      public boolean hasWarnings()
      Check if there are warnings 检查是否有警告
      Returns:
      true if there are warnings | 如果有警告返回true
    • errorCount

      public int errorCount()
      Get the count of errors 获取错误数量
      Returns:
      error count | 错误数量
    • warningCount

      public int warningCount()
      Get the count of warnings 获取警告数量
      Returns:
      warning count | 警告数量
    • merge

      public ValidationResult merge(ValidationResult other)
      Merge with another validation result 与另一个验证结果合并
      Parameters:
      other - the other validation result | 另一个验证结果
      Returns:
      merged validation result | 合并的验证结果
    • toString

      public String toString()
      Overrides:
      toString in class Object