Class MessageBatchResult
-
- All Implemented Interfaces:
public final class MessageBatchResultProcessing result for this request.
Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceMessageBatchResult.VisitorAn interface that defines how to map each variant of MessageBatchResult to a value of type T.
public final classMessageBatchResult.Type
-
Method Summary
-
-
Method Detail
-
succeeded
final Optional<MessageBatchSucceededResult> succeeded()
-
errored
final Optional<MessageBatchErroredResult> errored()
-
canceled
final Optional<MessageBatchCanceledResult> canceled()
-
expired
final Optional<MessageBatchExpiredResult> expired()
-
type
final MessageBatchResult.Type type()
-
isSucceeded
final Boolean isSucceeded()
-
isCanceled
final Boolean isCanceled()
-
asSucceeded
final MessageBatchSucceededResult asSucceeded()
-
asErrored
final MessageBatchErroredResult asErrored()
-
asCanceled
final MessageBatchCanceledResult asCanceled()
-
asExpired
final MessageBatchExpiredResult asExpired()
-
accept
final <T extends Any> T accept(MessageBatchResult.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = messageBatchResult.accept(new MessageBatchResult.Visitor<Optional<String>>() { @Override public Optional<String> visitSucceeded(MessageBatchSucceededResult succeeded) { return Optional.of(succeeded.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final MessageBatchResult validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofSucceeded
final static MessageBatchResult ofSucceeded(MessageBatchSucceededResult succeeded)
-
ofSucceeded
final static MessageBatchResult ofSucceeded(Message message)
Returns an immutable instance of MessageBatchResult whose ofSucceeded variant is built from the given required message.
-
ofErrored
final static MessageBatchResult ofErrored(MessageBatchErroredResult errored)
-
ofErrored
final static MessageBatchResult ofErrored(ErrorResponse error)
Returns an immutable instance of MessageBatchResult whose ofErrored variant is built from the given required error.
-
ofCanceled
final static MessageBatchResult ofCanceled(MessageBatchCanceledResult canceled)
-
ofExpired
final static MessageBatchResult ofExpired(MessageBatchExpiredResult expired)
-
-
-
-