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 | 如果验证通过且无错误则为trueerrors- unmodifiable list of validation errors | 不可修改的验证错误列表
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 Summary
ConstructorsConstructorDescriptionCsvValidationResult(boolean valid, List<CsvValidationError> errors) Canonical constructor - validates and defensively copies errors 规范构造器 - 验证并防御性复制错误列表 -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.errors()Returns the value of theerrorsrecord component.static CsvValidationResultfailure(List<CsvValidationError> errors) Creates a failed validation result with the given errors 创建带有给定错误的失败验证结果final inthashCode()Returns a hash code value for this object.static CsvValidationResultsuccess()Creates a successful validation result with no errors 创建无错误的成功验证结果final StringtoString()Returns a string representation of this record class.booleanvalid()Returns the value of thevalidrecord component.
-
Constructor Details
-
CsvValidationResult
Canonical constructor - validates and defensively copies errors 规范构造器 - 验证并防御性复制错误列表- Parameters:
valid- validity flag | 有效性标志errors- the errors | 错误列表
-
-
Method Details
-
success
Creates a successful validation result with no errors 创建无错误的成功验证结果- Returns:
- a successful result | 成功结果
-
failure
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为nullIllegalArgumentException- if errors is empty | 如果errors为空
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
valid
-
errors
-