Record Class CsvValidationResult

java.lang.Object
java.lang.Record
cloud.opencode.base.csv.validator.CsvValidationResult
Record Components:
valid - true if validation passed with no errors | 如果验证通过且无错误则为true
errors - unmodifiable list of validation errors | 不可修改的验证错误列表

public record CsvValidationResult(boolean valid, List<CsvValidationError> errors) extends Record
CSV Validation Result - Aggregated result of CSV document validation CSV验证结果 - CSV文档验证的聚合结果

Contains the overall validity flag and a list of all validation errors found. Use the static factory methods success() and failure(List) to create instances.

包含整体有效性标志和发现的所有验证错误列表。 使用静态工厂方法 success()failure(List) 创建实例。

Usage Examples | 使用示例:

CsvValidationResult ok = CsvValidationResult.success();
assert ok.valid();
assert ok.errors().isEmpty();

CsvValidationResult fail = CsvValidationResult.failure(List.of(error1, error2));
assert !fail.valid();
Since:
JDK 25, opencode-base-csv V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • CsvValidationResult

      public CsvValidationResult(boolean valid, List<CsvValidationError> errors)
      Canonical constructor - validates and defensively copies errors 规范构造器 - 验证并防御性复制错误列表
      Parameters:
      valid - validity flag | 有效性标志
      errors - the errors | 错误列表
  • Method Details

    • success

      public static CsvValidationResult success()
      Creates a successful validation result with no errors 创建无错误的成功验证结果
      Returns:
      a successful result | 成功结果
    • failure

      public static CsvValidationResult failure(List<CsvValidationError> errors)
      Creates a failed validation result with the given errors 创建带有给定错误的失败验证结果
      Parameters:
      errors - the validation errors (must not be empty) | 验证错误(不能为空)
      Returns:
      a failed result | 失败结果
      Throws:
      NullPointerException - if errors is null | 如果errors为null
      IllegalArgumentException - if errors is empty | 如果errors为空
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • valid

      public boolean valid()
      Returns the value of the valid record component.
      Returns:
      the value of the valid record component
    • errors

      public List<CsvValidationError> errors()
      Returns the value of the errors record component.
      Returns:
      the value of the errors record component