Record Class BatchResult
java.lang.Object
java.lang.Record
cloud.opencode.base.io.batch.BatchResult
- Record Components:
operation- the operation type | 操作类型totalCount- total number of items | 总项目数successCount- successful items | 成功项目数failureCount- failed items | 失败项目数skippedCount- skipped items | 跳过项目数failures- map of failed paths to exceptions | 失败路径到异常的映射startTime- operation start time | 操作开始时间endTime- operation end time | 操作结束时间
public record BatchResult(String operation, int totalCount, int successCount, int failureCount, int skippedCount, Map<Path, Throwable> failures, Instant startTime, Instant endTime)
extends Record
Batch Operation Result
批量操作结果
Immutable record containing the results of a batch file operation.
包含批量文件操作结果的不可变记录。
Features | 主要功能:
- Immutable result of batch file operations - 批量文件操作的不可变结果
- Success/failure/skipped counting - 成功/失败/跳过计数
- Duration and throughput calculation - 持续时间和吞吐量计算
- Failure details with path-to-exception mapping - 失败详情(路径到异常映射)
Usage Examples | 使用示例:
BatchResult result = OpenBatch.copyAll(files, targetDir);
if (result.isAllSuccess()) {
System.out.println("All " + result.totalCount() + " files copied");
} else {
result.failures().forEach((path, ex) -> System.err.println(path + ": " + ex));
}
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: No, constructor parameters must not be null - 空值安全: 否,构造器参数不可为null
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BatchResult.BuilderCreate a builder 创建构建器duration()Get operation duration 获取操作耗时endTime()Returns the value of theendTimerecord component.final booleanIndicates whether some other object is "equal to" this one.Get failed paths 获取失败的路径intReturns the value of thefailureCountrecord component.failures()Returns the value of thefailuresrecord component.getFailure(Path path) Get exception for a specific path 获取特定路径的异常booleanCheck if any operation failed 检查是否有失败final inthashCode()Returns a hash code value for this object.booleanCheck if all operations succeeded 检查是否全部成功booleanCheck if operation was partially successful 检查是否部分成功Returns the value of theoperationrecord component.intReturns the value of theskippedCountrecord component.Returns the value of thestartTimerecord component.intReturns the value of thesuccessCountrecord component.doubleGet success rate 获取成功率summary()Get summary string 获取摘要字符串toString()Returns a string representation of this record class.intReturns the value of thetotalCountrecord component.
-
Constructor Details
-
BatchResult
public BatchResult(String operation, int totalCount, int successCount, int failureCount, int skippedCount, Map<Path, Throwable> failures, Instant startTime, Instant endTime) Creates an instance of aBatchResultrecord class.- Parameters:
operation- the value for theoperationrecord componenttotalCount- the value for thetotalCountrecord componentsuccessCount- the value for thesuccessCountrecord componentfailureCount- the value for thefailureCountrecord componentskippedCount- the value for theskippedCountrecord componentfailures- the value for thefailuresrecord componentstartTime- the value for thestartTimerecord componentendTime- the value for theendTimerecord component
-
-
Method Details
-
isAllSuccess
public boolean isAllSuccess()Check if all operations succeeded 检查是否全部成功- Returns:
- true if no failures | 如果没有失败返回 true
-
hasFailures
public boolean hasFailures()Check if any operation failed 检查是否有失败- Returns:
- true if any failure | 如果有失败返回 true
-
isPartialSuccess
public boolean isPartialSuccess()Check if operation was partially successful 检查是否部分成功- Returns:
- true if some succeeded and some failed | 如果部分成功部分失败返回 true
-
duration
-
successRate
public double successRate()Get success rate 获取成功率- Returns:
- success rate (0.0 to 1.0) | 成功率(0.0 到 1.0)
-
failedPaths
-
getFailure
-
summary
-
toString
-
builder
Create a builder 创建构建器- Parameters:
operation- the operation type | 操作类型- Returns:
- builder | 构建器
-
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. -
operation
-
totalCount
public int totalCount()Returns the value of thetotalCountrecord component.- Returns:
- the value of the
totalCountrecord component
-
successCount
public int successCount()Returns the value of thesuccessCountrecord component.- Returns:
- the value of the
successCountrecord component
-
failureCount
public int failureCount()Returns the value of thefailureCountrecord component.- Returns:
- the value of the
failureCountrecord component
-
skippedCount
public int skippedCount()Returns the value of theskippedCountrecord component.- Returns:
- the value of the
skippedCountrecord component
-
failures
-
startTime
-
endTime
-