Package com.anthropic.models.messages
Class DocumentBlockParam.Source
-
- All Implemented Interfaces:
public final class DocumentBlockParam.Source
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceDocumentBlockParam.Source.VisitorAn interface that defines how to map each variant of Source to a value of type T.
-
Method Summary
-
-
Method Detail
-
base64
final Optional<Base64PdfSource> base64()
-
text
final Optional<PlainTextSource> text()
-
content
final Optional<ContentBlockSource> content()
-
url
final Optional<UrlPdfSource> url()
-
asBase64
final Base64PdfSource asBase64()
-
asText
final PlainTextSource asText()
-
asContent
final ContentBlockSource asContent()
-
asUrl
final UrlPdfSource asUrl()
-
accept
final <T extends Any> T accept(DocumentBlockParam.Source.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 = source.accept(new Source.Visitor<Optional<String>>() { @Override public Optional<String> visitBase64(Base64PdfSource base64) { return Optional.of(base64.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final DocumentBlockParam.Source 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.
-
ofBase64
final static DocumentBlockParam.Source ofBase64(Base64PdfSource base64)
-
ofText
final static DocumentBlockParam.Source ofText(PlainTextSource text)
-
ofContent
final static DocumentBlockParam.Source ofContent(ContentBlockSource content)
-
ofUrl
final static DocumentBlockParam.Source ofUrl(UrlPdfSource url)
-
-
-
-