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.
-
Method Summary
Modifier and Type Method Description final Optional<Base64ImageSource>base64()final Optional<UrlImageSource>url()final BooleanisBase64()final BooleanisUrl()final Base64ImageSourceasBase64()final UrlImageSourceasUrl()final Optional<JsonValue>_json()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)-
-
Method Detail
-
base64
final Optional<Base64ImageSource> base64()
-
url
final Optional<UrlImageSource> url()
-
asBase64
final Base64ImageSource asBase64()
-
asUrl
final UrlImageSource asUrl()
-
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)
-
-
-
-