Package com.anthropic.models.messages
Class WebSearchToolResultBlockContent
-
- All Implemented Interfaces:
public final class WebSearchToolResultBlockContent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceWebSearchToolResultBlockContent.VisitorAn interface that defines how to map each variant of WebSearchToolResultBlockContent to a value of type T.
-
Method Summary
-
-
Method Detail
-
error
final Optional<WebSearchToolResultError> error()
-
resultBlocks
final Optional<List<WebSearchResultBlock>> resultBlocks()
-
toParam
final WebSearchToolResultBlockParamContent toParam()
-
isResultBlocks
final Boolean isResultBlocks()
-
asError
final WebSearchToolResultError asError()
-
asResultBlocks
final List<WebSearchResultBlock> asResultBlocks()
-
accept
final <T extends Any> T accept(WebSearchToolResultBlockContent.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 = webSearchToolResultBlockContent.accept(new WebSearchToolResultBlockContent.Visitor<Optional<String>>() { @Override public Optional<String> visitError(WebSearchToolResultError error) { return Optional.of(error.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final WebSearchToolResultBlockContent 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.
-
ofError
final static WebSearchToolResultBlockContent ofError(WebSearchToolResultError error)
-
ofError
final static WebSearchToolResultBlockContent ofError(WebSearchToolResultErrorCode errorCode)
Returns an immutable instance of WebSearchToolResultBlockContent whose ofError variant is built from the given required errorCode.
-
ofResultBlocks
final static WebSearchToolResultBlockContent ofResultBlocks(List<WebSearchResultBlock> resultBlocks)
-
-
-
-