Record Class BatchResult
java.lang.Object
java.lang.Record
cloud.opencode.base.sms.batch.BatchResult
- Record Components:
results- individual results | 单条结果列表totalCount- total message count | 总消息数successCount- success count | 成功数failureCount- failure count | 失败数startTime- batch start time | 批次开始时间endTime- batch end time | 批次结束时间
public record BatchResult(List<SmsResult> results, int totalCount, int successCount, int failureCount, Instant startTime, Instant endTime)
extends Record
Batch Result
批量发送结果
Aggregated result of batch SMS sending.
批量短信发送的聚合结果。
Features | 主要功能:
- Success/failure counts and timing - 成功/失败计数和耗时
- Individual result access - 单条结果访问
- Immutable result record - 不可变结果记录
Usage Examples | 使用示例:
BatchResult result = BatchResult.of(resultList, startTime);
boolean allOk = result.isAllSuccess();
int failures = result.failureCount();
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Since:
- JDK 25, opencode-base-sms V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBatchResult(List<SmsResult> results, int totalCount, int successCount, int failureCount, Instant startTime, Instant endTime) Creates an instance of aBatchResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic BatchResultempty()Create empty batch result 创建空批量结果endTime()Returns the value of theendTimerecord component.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of thefailureCountrecord component.Get duration 获取耗时Get failure counts by error code 按错误码获取失败统计Get failure results 获取失败结果doubleGet success rate 获取成功率Get success results 获取成功结果doubleGet throughput (messages per second) 获取吞吐量(每秒消息数)final inthashCode()Returns a hash code value for this object.booleanCheck if all failed 检查是否全部失败booleanCheck if all succeeded 检查是否全部成功booleanCheck if partial success 检查是否部分成功static BatchResultCreate batch result from results 从结果列表创建批量结果results()Returns the value of theresultsrecord component.Returns the value of thestartTimerecord component.intReturns the value of thesuccessCountrecord component.toString()Returns a string representation of this record class.intReturns the value of thetotalCountrecord component.
-
Constructor Details
-
BatchResult
public BatchResult(List<SmsResult> results, int totalCount, int successCount, int failureCount, Instant startTime, Instant endTime) Creates an instance of aBatchResultrecord class.- Parameters:
results- the value for theresultsrecord componenttotalCount- the value for thetotalCountrecord componentsuccessCount- the value for thesuccessCountrecord componentfailureCount- the value for thefailureCountrecord componentstartTime- the value for thestartTimerecord componentendTime- the value for theendTimerecord component
-
-
Method Details
-
of
Create batch result from results 从结果列表创建批量结果- Parameters:
results- the results | 结果列表startTime- the start time | 开始时间- Returns:
- the batch result | 批量结果
-
empty
-
isAllSuccess
public boolean isAllSuccess()Check if all succeeded 检查是否全部成功- Returns:
- true if all succeeded | 如果全部成功返回true
-
isAllFailed
public boolean isAllFailed()Check if all failed 检查是否全部失败- Returns:
- true if all failed | 如果全部失败返回true
-
isPartialSuccess
public boolean isPartialSuccess()Check if partial success 检查是否部分成功- Returns:
- true if partial | 如果部分成功返回true
-
getSuccessRate
public double getSuccessRate()Get success rate 获取成功率- Returns:
- the success rate (0.0 - 1.0) | 成功率
-
getDuration
-
getSuccessResults
-
getFailureResults
-
getFailureCountsByCode
-
getThroughput
public double getThroughput()Get throughput (messages per second) 获取吞吐量(每秒消息数)- Returns:
- the throughput | 吞吐量
-
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. -
results
-
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
-
startTime
-
endTime
-