Package com.anthropic.models.messages
Class ImageBlockParam.Source
-
- All Implemented Interfaces:
public final class ImageBlockParam.Source
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceImageBlockParam.Source.VisitorAn interface that defines how to map each variant of Source to a value of type T.
public final classImageBlockParam.Source.Type
-
Method Summary
Modifier and Type Method Description final Optional<Base64ImageSource>base64()final Optional<UrlImageSource>url()final Optional<FileImageSource>file()final Optional<JsonValue>_json()final ImageBlockParam.Source.Typetype()final BooleanisBase64()final BooleanisUrl()final BooleanisFile()final Base64ImageSourceasBase64()final UrlImageSourceasUrl()final FileImageSourceasFile()final <T extends Any> Taccept(ImageBlockParam.Source.Visitor<T> visitor)Maps this instance's current variant to a value of type T using the given visitor. final ImageBlockParam.Sourcevalidate()Validates that the types of all values in this object match their expected types recursively. final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static ImageBlockParam.SourceofBase64(Base64ImageSource base64)final static ImageBlockParam.SourceofUrl(UrlImageSource url)final static ImageBlockParam.SourceofUrl(String url)Returns an immutable instance of Source whose ofUrl variant is built from the given required url. final static ImageBlockParam.SourceofFile(FileImageSource file)final static ImageBlockParam.SourceofFile(String fileId)Returns an immutable instance of Source whose ofFile variant is built from the given required fileId. -
-
Method Detail
-
base64
final Optional<Base64ImageSource> base64()
-
url
final Optional<UrlImageSource> url()
-
file
final Optional<FileImageSource> file()
-
type
final ImageBlockParam.Source.Type type()
-
asBase64
final Base64ImageSource asBase64()
-
asUrl
final UrlImageSource asUrl()
-
asFile
final FileImageSource asFile()
-
accept
final <T extends Any> T accept(ImageBlockParam.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(Base64ImageSource base64) { return Optional.of(base64.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ImageBlockParam.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 ImageBlockParam.Source ofBase64(Base64ImageSource base64)
-
ofUrl
final static ImageBlockParam.Source ofUrl(UrlImageSource url)
-
ofUrl
final static ImageBlockParam.Source ofUrl(String url)
-
ofFile
final static ImageBlockParam.Source ofFile(FileImageSource file)
-
-
-
-