Interface BatchItemResult<T>
- Type Parameters:
T- the type of a successful response payload (e.g.,ChatResponse,Embedding)
- All Known Implementing Classes:
BatchItemResult.Failure, BatchItemResult.Success
@Experimental
public sealed interface BatchItemResult<T>
permits BatchItemResult.Success<T>, BatchItemResult.Failure<T>
Represents the outcome of a single request within a batch operation.
Each batch request is processed independently and either succeeds (producing a response) or
fails (producing a BatchError). The results of a batch are returned in the same order as
the input requests, so the i-th BatchItemResult corresponds to the i-th submitted request,
allowing the caller to correlate every outcome with its originating request even when only some
requests fail.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordThe failed outcome of a single batch request.static final recordThe successful outcome of a single batch request. -
Method Summary
Modifier and TypeMethodDescription@Nullable BatchErrorerror()Returns the error, ornullif this request succeeded.static <T> BatchItemResult<T> failure(BatchError error) Creates a failedBatchItemResult.booleanReturnstrueif this request succeeded.@Nullable Tresponse()Returns the successful response, ornullif this request failed.static <T> BatchItemResult<T> success(T response) Creates a successfulBatchItemResult.
-
Method Details
-
isSuccess
boolean isSuccess()Returnstrueif this request succeeded. -
response
@Nullable T response()Returns the successful response, ornullif this request failed. -
error
@Nullable BatchError error()Returns the error, ornullif this request succeeded. -
success
Creates a successfulBatchItemResult. -
failure
Creates a failedBatchItemResult.
-